Saturday, 1 June 2013

How do I make a subsection title visible in a header on page with chapter / section

How do I make a subsection title visible in a header on page with chapter / section

Could someone please give me a hand to correctly use \markboth{}{} within redefinition of the \sectionmark? I am struggling to apply the second parameter in \markboth. The article I am writing needs to have both section and subsection titles on all pages. I read Header not displaying correctly on chapter page due to subsection and understood that \chapter or \section commands make the \markright field empty and therefore subsection does not appear on pages where \chapter or \section is issued. I still cannot understand how to make this work. I will be grateful for any help.
PS. Below is the LaTeX code. I am compiling the article using XeLaTeX.
\documentclass[11pt]{article}
\special{papersize=210mm,297mm}

\title{\bfseries Factor Analysis}
\author{J. Smith}

% Set font
\usepackage{unicode-math}
\setmainfont[Ligatures=TeX]{Cambria}
\setmathfont{Cambria Math}

% if then
\usepackage{ifthen}

\usepackage[a4paper,portrait,hmargin=2.54cm,vmargin=2.54cm,bindingoffset=0cm,includehead,includefoot]{geometry} % Document margins
\geometry{headheight=14pt}

% Multi columns
%\usepackage{paralist} % Used for the "compactitem" environment which makes bullet points with less space between them
\usepackage{multicol} % Used for the two-column layout of the document
\setlength{\columnsep}{20pt}

% Fancy headers
\usepackage{fancyhdr} % Headers and footers
\pagestyle{fancy} % All pages have headers and footers
\fancyhf{} % clear all headers and footers - equivalent to %\fancyhead{} and \fancyfoot{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\newcommand{\mymarks}{
    \ifthenelse{\equal{\rightmark}{}} % is \rightmark empty?
        {\leftmark} % when empty
        {\leftmark\ --\ \itshape\rightmark} % when not empty
}
\renewcommand{\sectionmark}[1]{\markboth{\thesection.\ #1}{}}
\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyhead[C]{\mymarks} % Custom header text
\fancyfoot[C]{\thepage} % Custom footer text

\usepackage{graphicx}
\usepackage{url} % allows escaping special characters inside a hyper links in a bibliography such as %20 etc.
\usepackage[round]{natbib}
\usepackage{setspace}
\usepackage[format=hang,font=small,labelfont=bf]{caption} % Custom captions under/above floats in tables or figures

% Links in PDF
%\usepackage[hidelinks]{hyperref}
\usepackage{hyperref}
\hypersetup{
    bookmarks=false,         % show bookmarks bar?
    pdftoolbar=true,        % show Acrobat’s toolbar?
    pdfmenubar=true,        % show Acrobat’s menu?
    pdffitwindow=false,     % window fit to page when opened
    pdfstartview={FitH},    % fits the width of the page to the window
    pdftitle={Exposure response relationship to noise in the presence of vibration},    % title
    pdfauthor={Zbigniew Koziel},     % author
    pdfsubject={Environmental Noise and Vibration},   % subject of the document
    pdfcreator={Zbigniew Koziel},   % creator of the document
    pdfproducer={Zbigniew Koziel}, % producer of the document
    pdfkeywords={noise} {vibration} {exposure response-relationship}, % list of keywords
    pdfnewwindow=true,      % links in new window
    colorlinks=true,
    citecolor=blue,
    linkcolor=red,      % color

No comments:

Post a Comment