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).
Post Reply
tisaigon
Posts: 3
Joined: Fri Feb 23, 2018 9:04 am

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

Post by tisaigon »

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

Code: Select all

\
\documentclass[a4paper,11pt]{book}
\usepackage{import}
\usepackage{example}

\usepackage[utf8]{inputenc}
\usepackage[utf8]{vietnam}
%\usepackage[utf8]{english}


\usepackage[none]{hyphenat}
%\usepackage{hyphenat}

%\usepackage[english]{babel}

\usepackage{xcolor}
\usepackage{lipsum}
%\usepackage{tabularx}
\usepackage{longtable}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{geometry} 

\usepackage{fancyhdr}
\usepackage{lastpage}

\usepackage{ragged2e}

\usepackage{hyperref}
%\hypersetup{linktocpage}
%\renewcommand{\theHsection}{\thepart.section.\thesection}

%\usepackage{placeins}
\usepackage[section]{placeins}
\usepackage{float}

%\hypersetup{
%    colorlinks=true, %set true if you want colored links
%    linktoc=all,     %set to all if you want both sections and subsections linked
%    linkcolor=blue,  %choose some color if you want links to stand out
%}

\usepackage{booktabs}
\usepackage{array}

\usepackage{microtype}

%\DeclareCaptionTextFormat{new}{\nohyphens{#1}}

\geometry{a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,}

%Đổi tên chapter, section
\usepackage{titlesec}
%\usepackage{fixltx2e}

\usepackage{eurosym}
\usepackage{makeidx}
\makeindex



\pagestyle{fancy}
\fancyhf{}

\rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
\renewcommand{\headrule}{}


%\titleformat

%{\chapter} % command
%[display] % shape
%{\bfseries\Large\itshape} % format
%{CHAPTER No. \ \thechapter} % label
%{0.5ex} % sep
{
%    \rule{\textwidth}{1pt}
%    \vspace{1ex}
%    \centering
} % before-code
%[
%\vspace{-0.5ex}%
%\rule{\textwidth}{0.3pt}
%] % after-code
%=====================
%\chapter{The Fourth Industrial Revolution \\
%Cách mạng công nghệ lần thứ Tư}

\usepackage{chngcntr}
%\counterwithout{section}{chapter}

\newcommand{\periodafter}[1]{#1.}

\titleformat{\chapter}[frame]
  {\normalfont}
  {\filright\small\enspace\MakeUppercase{\chaptertitlename}~\thechapter\enspace}
  {20pt}
  {\Large\filcenter}
  
\titleformat{\section}[runin]
  {\normalfont\large\bfseries}{\thesection}{1em}{\periodafter}
\titlespacing*{\section}
  {0pt}{3.5ex plus 1ex minus .2ex}{0.5em}



%Nguồn sách
\fancyfoot[LO]{Source: Industry 4.0 - Klaus Schwab and others}
%Chỉ dành cho nội bộ
\fancyfoot[LE]{For internal circulation only}
%Tiêu đề chương trên header 
\fancyhead[LO]{\rightmark}
%Song ngữ-DataMining
\fancyhead[LE]{Data Mining }
%Giới thiệu công ty
\fancyhead[RE,RO]{BenhVienOTo}


%\renewcommand{\contentsname}{Whatever}

\usepackage[english]{babel}

\addto\captionsenglish{% Replace "english" with the language you use
  \renewcommand{\contentsname}%
    {Table of contents }%
}

\begin{document}


{\pagestyle{plain}
\tableofcontents
\cleardoublepage}

%\clearpage
%\frontmatter

%\pagenumbering{num_style}

\pagenumbering{arabic}


\import{Intro/}{Introduction.tex}



%/Chapter A1
\import{Chapter_A1/}{a1.tex}

\section{Historical Context - Bối cảnh lịch sử}
\import{Chapter_A1/}{sectiona1-1.tex}
%
\section{Profound and Systemic Change}

\import{Chapter_A1/}{sectiona1-2.tex}



\end{document}

....
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 197 times
need chapter name.png
need chapter name.png (59.61 KiB) Viewed 4643 times
Last edited by tisaigon on Sat Feb 24, 2018 1:57 pm, edited 4 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

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

Post by Johannes_B »

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

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

Post by tisaigon »

@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: 4182
Joined: Thu Nov 01, 2012 4:08 pm

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

Post by Johannes_B »

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.
Post Reply