问题

问题

问题

如何将部分名称放在自定义样式的每个页面的右上角标题中主要内容,但没有数字。我不需要任何子部分:仅部分。

问题

首先,我对LaTeX中的标记命令的理解并不完整:

  • \leftmark (更高级别)=无论这意味着什么……章节?
  • \rightmark(较低级别)=无论这意味着什么……小节?
  • \markboth

这取自 2004 年 3 月 2 日 fancyhdr 文档版本第 9 章“有关 LaTeX 标记的独家新闻”。

其次,我似乎无法得到\renewcommand{\sectionmark}[1]{\markright{#1}}得到这个问题上班。

例子

\documentclass[10pt]{article}
\usepackage[quiet]{fontspec}
% !TEX TS-program = XeLaTeX
\setmainfont{SourceSansPro}[%
%    Path= /usr/local/texlive/2014/texmf-dist/fonts/opentype/adobe/sourcesanspro/ ,
    Extension = .otf ,
    UprightFont = *-Regular ,
    ItalicFont = *-RegularIt ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldIt ]
\usepackage[%
    a4paper,
%   includeheadfoot,
    head=\baselineskip,  % distance from bottom of header to block of text aka \headsep e.g. \baselineskip
    foot=2.3cm,  % distance from top of footer to block of text aka \footskip
    headheight=12pt,     % height for the header block (no equivalent for footer)
%   heightrounded,       % ensure an integer number of lines
    marginparwidth=2cm,  % right marginal note width
    marginparsep=2mm,    % distance from text block to marginal note box
%   height=\textheight,  % height of the text block
%   width=\textwidth,    % width of the text block
    top=2.5cm,           % distance of the text block from the top of the page
    bottom=3cm,
    left=2.5cm,
    right=2.5cm,
%    showframe,           % show the main blocks
%    verbose,             % show the values of the parameters in the log file
]{geometry}

\usepackage{fancyhdr}


\pagestyle{fancy} % This must be here, because defaults are set and renewcommand for section marks will work.
\renewcommand{\sectionmark}[1]{\markright{#1}}


%Fancyhdr Styles
\fancypagestyle{frontmatter}{%
   \fancyhf{} % clear all fields
   \renewcommand{\headrulewidth}{0pt}
   \lhead{}
   \lfoot{}
   \cfoot{}
   \rfoot{}
}%
\fancypagestyle{mainmatter}{%
   \fancyhf{} % clear all fields
   \renewcommand{\headrulewidth}{0pt}
   \lhead{Test Left Header}
   \rhead{\leftmark}
   \lfoot{}
   \cfoot{}
   \rfoot{}
}%

\begin{document}
\pagestyle{frontmatter}
\section{Monkey}
Some text about monkeys.
\newpage
\pagestyle{mainmatter}
\section{Yack}
Some text about yacks.
\newpage
\section{Alpine ibex}
Some text about alpine ibexes.
\end{document}

答案1

您必须在 pagestyle的定义中更改\leftmark为。\rightmarkmainmatter

你还必须消除\subsectionmark

\renewcommand{\subsectionmark}[1]{}

平均能量损失

\documentclass[10pt]{article}
\usepackage[quiet]{fontspec}
% !TEX TS-program = XeLaTeX
\setmainfont{SourceSansPro}[%
%    Path= /usr/local/texlive/2014/texmf-dist/fonts/opentype/adobe/sourcesanspro/ ,
    Extension = .otf ,
    UprightFont = *-Regular ,
    ItalicFont = *-RegularIt ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldIt ]
\usepackage[%
    a4paper,
%   includeheadfoot,
    head=\baselineskip,  % distance from bottom of header to block of text aka \headsep e.g. \baselineskip
    foot=2.3cm,  % distance from top of footer to block of text aka \footskip
    headheight=12pt,     % height for the header block (no equivalent for footer)
%   heightrounded,       % ensure an integer number of lines
    marginparwidth=2cm,  % right marginal note width
    marginparsep=2mm,    % distance from text block to marginal note box
%   height=\textheight,  % height of the text block
%   width=\textwidth,    % width of the text block
    top=2.5cm,           % distance of the text block from the top of the page
    bottom=3cm,
    left=2.5cm,
    right=2.5cm,
%    showframe,           % show the main blocks
%    verbose,             % show the values of the parameters in the log file
]{geometry}

\usepackage{fancyhdr}

\usepackage{lipsum}


\pagestyle{fancy} % This must be here, because defaults are set and renewcommand for section marks will work.
\renewcommand{\sectionmark}[1]{\markright{#1}}
\renewcommand{\subsectionmark}[1]{}


%Fancyhdr Styles
\fancypagestyle{frontmatter}{%
   \fancyhf{} % clear all fields
   \renewcommand{\headrulewidth}{0pt}
   \lhead{}
   \lfoot{}
   \cfoot{}
   \rfoot{}
}%
\fancypagestyle{mainmatter}{%
   \fancyhf{} % clear all fields
   \renewcommand{\headrulewidth}{0pt}
   \lhead{Test Left Header}
   \rhead{\rightmark}
   \lfoot{}
   \cfoot{}
   \rfoot{}
}%

\begin{document}
\pagestyle{frontmatter}
\section{Monkey}
Some text about monkeys.
\lipsum[1-20]
\newpage
\pagestyle{mainmatter}
\section{Yack}
Some text about yacks.
\lipsum[1-20]
\newpage
\section{Alpine ibex}
\subsection{A subsection}
Some text about alpine ibexes.
\lipsum[1-20]
\end{document} 

输出:

在此处输入图片描述

相关内容