LaTeX forum ⇒ Page LayoutHeader display chapter name if don't have section in this chapter

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
tisaigon
Posts: 3
Joined: Fri Feb 23, 2018 9:04 am

Header display chapter name if don't have section in this chapter

Postby tisaigon » Sat Feb 24, 2018 1:03 pm

Hi all,
i have chapter and this chapter don't have section: ex: infomation chapter, Acknowledgment chapter.
My latex:
Link in overleaf: https://www.overleaf.com/13998715dxwtfgqcqcby
  1. \
  2. \documentclass[a4paper,11pt]{book}
  3. \usepackage{import}
  4. \usepackage{example}
  5.  
  6. \usepackage[utf8]{inputenc}
  7. \usepackage[utf8]{vietnam}
  8. %\usepackage[utf8]{english}
  9.  
  10.  
  11. \usepackage[none]{hyphenat}
  12. %\usepackage{hyphenat}
  13.  
  14. %\usepackage[english]{babel}
  15.  
  16. \usepackage{xcolor}
  17. \usepackage{lipsum}
  18. %\usepackage{tabularx}
  19. \usepackage{longtable}
  20.  
  21. \usepackage{natbib}
  22. \usepackage{graphicx}
  23. \usepackage{booktabs}
  24. \usepackage{amsmath}
  25. \usepackage{siunitx}
  26. \usepackage{geometry}
  27.  
  28. \usepackage{fancyhdr}
  29. \usepackage{lastpage}
  30.  
  31. \usepackage{ragged2e}
  32.  
  33. \usepackage{hyperref}
  34. %\hypersetup{linktocpage}
  35. %\renewcommand{\theHsection}{\thepart.section.\thesection}
  36.  
  37. %\usepackage{placeins}
  38. \usepackage[section]{placeins}
  39. \usepackage{float}
  40.  
  41. %\hypersetup{
  42. % colorlinks=true, %set true if you want colored links
  43. % linktoc=all, %set to all if you want both sections and subsections linked
  44. % linkcolor=blue, %choose some color if you want links to stand out
  45. %}
  46.  
  47. \usepackage{booktabs}
  48. \usepackage{array}
  49.  
  50. \usepackage{microtype}
  51.  
  52. %\DeclareCaptionTextFormat{new}{\nohyphens{#1}}
  53.  
  54. \geometry{a4paper,
  55. total={170mm,257mm},
  56. left=20mm,
  57. top=20mm,}
  58.  
  59. %Đổi tên chapter, section
  60. \usepackage{titlesec}
  61. %\usepackage{fixltx2e}
  62.  
  63. \usepackage{eurosym}
  64. \usepackage{makeidx}
  65. \makeindex
  66.  
  67.  
  68.  
  69. \pagestyle{fancy}
  70. \fancyhf{}
  71.  
  72. \rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
  73. \renewcommand{\headrule}{}
  74.  
  75.  
  76. %\titleformat
  77.  
  78. %{\chapter} % command
  79. %[display] % shape
  80. %{\bfseries\Large\itshape} % format
  81. %{CHAPTER No. \ \thechapter} % label
  82. %{0.5ex} % sep
  83. {
  84. % \rule{\textwidth}{1pt}
  85. % \vspace{1ex}
  86. % \centering
  87. } % before-code
  88. %[
  89. %\vspace{-0.5ex}%
  90. %\rule{\textwidth}{0.3pt}
  91. %] % after-code
  92. %=====================
  93. %\chapter{The Fourth Industrial Revolution \\
  94. %Cách mạng công nghệ lần thứ Tư}
  95.  
  96. \usepackage{chngcntr}
  97. %\counterwithout{section}{chapter}
  98.  
  99. \newcommand{\periodafter}[1]{#1.}
  100.  
  101. \titleformat{\chapter}[frame]
  102. {\normalfont}
  103. {\filright\small\enspace\MakeUppercase{\chaptertitlename}~\thechapter\enspace}
  104. {20pt}
  105. {\Large\filcenter}
  106.  
  107. \titleformat{\section}[runin]
  108. {\normalfont\large\bfseries}{\thesection}{1em}{\periodafter}
  109. \titlespacing*{\section}
  110. {0pt}{3.5ex plus 1ex minus .2ex}{0.5em}
  111.  
  112.  
  113.  
  114. %Nguồn sách
  115. \fancyfoot[LO]{Source: Industry 4.0 - Klaus Schwab and others}
  116. %Chỉ dành cho nội bộ
  117. \fancyfoot[LE]{For internal circulation only}
  118. %Tiêu đề chương trên header
  119. \fancyhead[LO]{\rightmark}
  120. %Song ngữ-DataMining
  121. \fancyhead[LE]{Data Mining }
  122. %Giới thiệu công ty
  123. \fancyhead[RE,RO]{BenhVienOTo}
  124.  
  125.  
  126. %\renewcommand{\contentsname}{Whatever}
  127.  
  128. \usepackage[english]{babel}
  129.  
  130. \addto\captionsenglish{% Replace "english" with the language you use
  131. \renewcommand{\contentsname}%
  132. {Table of contents }%
  133. }
  134.  
  135. \begin{document}
  136.  
  137.  
  138. {\pagestyle{plain}
  139. \tableofcontents
  140. \cleardoublepage}
  141.  
  142. %\clearpage
  143. %\frontmatter
  144.  
  145. %\pagenumbering{num_style}
  146.  
  147. \pagenumbering{arabic}
  148.  
  149.  
  150. \import{Intro/}{Introduction.tex}
  151.  
  152.  
  153.  
  154. %/Chapter A1
  155. \import{Chapter_A1/}{a1.tex}
  156.  
  157. \section{Historical Context - Bối cảnh lịch sử}
  158. \import{Chapter_A1/}{sectiona1-1.tex}
  159. %
  160. \section{Profound and Systemic Change}
  161.  
  162. \import{Chapter_A1/}{sectiona1-2.tex}
  163.  
  164.  
  165.  
  166. \end{document}
  167.  
  168. ....

i want in 2 case/ situation:
case 1. If chapter have section, display section: \fancyhead[LO]{\rightmark}
case 2. if don't have section, display chapter in Left odd (LO): ??? in page pdf 3 (please compile in overleaf.
and how can remove blank page (page 4 pdf)
please see more in pdf attacht.
Thanks
how can i get it?
Please help
thanks
Attachments
untitled.pdf
(63.49 KiB) Downloaded 9 times
need chapter name.png
need chapter name.png (59.61 KiB) Viewed 1235 times
Last edited by tisaigon on Sat Feb 24, 2018 1:57 pm, edited 4 times in total.

User avatar
Johannes_B
Site Moderator
Posts: 3795
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Feb 24, 2018 1:18 pm

Please add a minimal working example, i.e. a short but complete LaTeX document we can compile and see your (unwanted) output.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

tisaigon
Posts: 3
Joined: Fri Feb 23, 2018 9:04 am

Postby tisaigon » Sat Feb 24, 2018 1:58 pm

@Johannes_B: Thank for your reply.
i have added:
- code in overleaf that can compile: https://www.overleaf.com/13998715dxwtfgqcqcby
- pdf file
- image file
Thanks

User avatar
Johannes_B
Site Moderator
Posts: 3795
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Feb 24, 2018 2:07 pm

Please don't link to an overleaf project. Produce an example and add it as a code block to your post.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 4 guests