例子

例子

我在花哨的标题/几何设置中弄乱了一些东西,我得到了标题行多于标题文本. 错误在哪里以及如何获取显示标题文本的默认行为多于这条线?

例子

怎么了

代码

% vim:ft=tex:
%
\documentclass[12pt, twoside]{article}

\usepackage{fontspec}
\setmainfont{Arial}

% Use if Arial font unavailable
% \usepackage{helvet}
% \renewcommand{\familydefault}{\sfdefault}

% Geometry has to be loaded before the footer
\usepackage[a4paper,left=20mm,top=20mm,bottom=20mm,bindingoffset=0mm]{geometry}

\usepackage{lastpage} % for the last page number
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

% Add a line above footer
\renewcommand{\footrulewidth}{0.4pt}% default is 0pt
% Define footer
\fancyfoot[EL,OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}
\fancyfoot[ER,OL]{\footnotesize \runauthor}

% Define header
\fancyhead[EL, OR]{\footnotesize \runtitle}
% Add line above footer
\renewcommand{\headrulewidth}{0.4pt}

% Define style to be used for the first page
\fancypagestyle{firststyle}
{
   \fancyhf{}
   \renewcommand{\headrulewidth}{0.0pt} % I would hope for this to delete header rule on the first page
   \fancyfoot[OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}
}



% Section font sizes
\usepackage{sectsty}
\sectionfont{\fontsize{14}{15}\selectfont}

% Title page configuration
\title{\vspace{-2cm}Title of the Document\vspace{-5mm}}
\author{Author Name\vspace{-5mm}}
\date{\today}


% Store author and report title for headers
\makeatletter
\let\runauthor\@author
\let\runtitle\@title
\makeatother

% Create line spacing
\linespread{1.25}

% Dummy text generation
\usepackage{lipsum}  


\begin{document}

% Use special first page style on the first page

\maketitle\thispagestyle{firststyle}

\section{Section}

\subsection{SubSection One}

\lipsum[2-4]

\subsection{SubSection Two}

\lipsum[3-5]

\section{Section Two}

\lipsum[1-5]

\end{document}

答案1

将标题\vspace{-5mm}移动bottom到文本上方,这就是绘制线条的位置。

我的建议是将实际标题放在 中\runtitle,然后在命令中使用它\title,而不是反过来。同样适用于\runauthor/\author

\documentclass[12pt, twoside]{article}

\usepackage{fontspec}
\setmainfont{Arial}

% Use if Arial font unavailable
% \usepackage{helvet}
% \renewcommand{\familydefault}{\sfdefault}

% Geometry has to be loaded before the footer
\usepackage[a4paper,left=20mm,top=20mm,bottom=20mm,bindingoffset=0mm]{geometry}

\usepackage{lastpage} % for the last page number
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

% Add a line above footer
\renewcommand{\footrulewidth}{0.4pt}% default is 0pt
% Define footer
\fancyfoot[EL,OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}
\fancyfoot[ER,OL]{\footnotesize \runauthor}

% Define header
\fancyhead[EL, OR]{\footnotesize \runtitle}
% Add line above footer
\renewcommand{\headrulewidth}{0.4pt}

% Define style to be used for the first page
\fancypagestyle{firststyle}
{
   \fancyhf{}
   \renewcommand{\headrulewidth}{0.0pt} % I would hope for this to delete header rule on the first page
   \fancyfoot[OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}
}



% Section font sizes
\usepackage{sectsty}
\sectionfont{\fontsize{14}{15}\selectfont}

% Title page configuration
\newcommand{\runtitle}{Title of the Document}
\newcommand{\runauthor}{Author Name}
\title{\vspace{-2cm}\runtitle\vspace{-5mm}}
\author{\runauthor\vspace{-5mm}}
\date{\today}

% Create line spacing
\linespread{1.25}

% Dummy text generation
\usepackage{lipsum}  


\begin{document}

% Use special first page style on the first page

\maketitle\thispagestyle{firststyle}

\section{Section}

\subsection{SubSection One}

\lipsum[2-4]

\subsection{SubSection Two}

\lipsum[3-5]

\section{Section Two}

\lipsum[1-5]

\end{document}

相关内容