我正在和一个非常糟糕的硕士论文模板作斗争。一些聪明的 _ss 设计了一些功能,如果不进行手动更正,这些功能在 MS Word 中是无法实现的,所以我试图让它在 LaTeX 中工作以破解它。
我坚持使用页眉和页脚。它们应该由一条水平线组成,与章节行和文本对齐。页眉应有大写的章节名称。页脚应有静态文本:文本块第一行上的“页面”,第二页上的奇数/偶数角编号。全部使用 Verdana 字体。
请参阅附图。
我试过,fandyhdr
但我的LaTeX
技术不够好。有人能帮我吗?谢谢。
这是我的模板代码:
\documentclass[a4paper,twoside]{report}% http://ctan.org/pkg/amsproc
\usepackage[top=3.00cm, bottom=3.00cm, inner=3cm, outer=3.5cm]{geometry}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[x11names,table]{xcolor}
\usepackage{fourier}
\usepackage{microtype}
\SetTracking[no ligatures={f}]{encoding=*}{80}
\usepackage[strict]{changepage}%
\usepackage{graphicx}
\usepackage[explicit]{titlesec}%
\usepackage[export]{adjustbox}
\usepackage{biblatex}
\usepackage{fancyhdr}
\usepackage{lipsum}
% BARVY
\definecolor{ukred}{RGB}{160,0,0}
\definecolor{ukgray}{RGB}{128,128,128}
\definecolor{ukredlight}{RGB}{160,0,0}
\definecolor{ukgraylight}{RGB}{192,192,192}
% TABULKY A OBRÁZKY
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\usepackage[font={color=ukgray},figurename=Obr.,tablename=Tab.,labelfont={color=ukgray,bf}]{caption}
\captionsetup{justification = raggedright,singlelinecheck = false}
\counterwithout{table}{chapter}
\rowcolors{1}{ukgraylight}{white}
\renewcommand{\contentsname}{Obsah}
% NUMBERS AND LINES AT CAPTIONS
\titleformat{\chapter}[hang]
{\bfseries\fontsize{14pt}{14pt}\selectfont\color{ukred}\lsstyle}
{\checkoddpage\ifoddpage\llap{\makebox[\dimexpr\marginparsep+\marginparwidth\relax][l]{\rule[-1.25ex]{\marginparwidth}{0.5ex}\llap{}}}\thechapter\enspace\else\thechapter\enspace \fi}
{0pt}
{\MakeUppercase{#1}\checkoddpage\ifoddpage\else\hfill\rlap{\makebox[\dimexpr\textwidth + \marginparsep][l]{\hspace{\marginparsep}\rlap{\rule[-1.25ex]{\marginparwidth}{0.5ex}}\thechapter}}\fi}%\titlerule[1.5pt]
\titlespacing*{\chapter}{0pt}{2ex}{1ex}
%
\titleformat{\section}
{\bfseries\large}
{\checkoddpage\ifoddpage\llap{\makebox[\dimexpr\marginparsep+\marginparwidth\relax][l]{\rule[-1.25ex]{\marginparwidth}{0.5ex}\llap{}}}\thesection\enspace\else\thesection\enspace \fi}
{0pt}
{#1\checkoddpage\ifoddpage\else\hfill\rlap{\makebox[\dimexpr\textwidth + \marginparsep][l]{\hspace{\marginparsep}\rlap{\smash{\rule[-1.25ex]{\marginparwidth}{0.5ex}}}\thesection}}\fi}%\titlerule[1.5pt]
\titlespacing*{\section}{0pt}{1ex}{0.5ex}
\titleformat{\subsection}
{\bfseries}
{\checkoddpage\ifoddpage\llap{\makebox[\dimexpr\marginparsep+\marginparwidth\relax][l]{\rule[-1.25ex]{\marginparwidth}{0.5ex}\llap{}}}\thesubsection\enspace\else\thesubsection\enspace \fi}
{0pt}
{#1\checkoddpage\ifoddpage\else\hfill\rlap{\makebox[\dimexpr\textwidth + \marginparsep][l]{\hspace{\marginparsep}\rlap{\smash{\rule[-1.25ex]{\marginparwidth}{0.5ex}}}\thesubsection}}\fi} \titlespacing*{\subsection}{0pt}{1ex}{0.5ex}
%%%%%%%%%
% HEADER
% FOOTER
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\color{ukgraylight}\hrule height 2.84pt \vspace{0.1cm} \textsf{\small{strana}\\ \vspace{0.15cm} \textbf{\Large{\thepage}}}}
% CITACE
\addbibresource{citace.bib}
\begin{document}
\tableofcontents
\chapter{Nadpis 1. úrovně}
\lipsum[1]
\section{Nadpis 2. úrovně}
\lipsum[2]
\subsection{Nadpis 3. úrovně}
\lipsum[3]
\chapter{První kapitola dizertace}
\lipsum[1]\par
Tady odcitujeme nějaký zdroj, ať víš, jak se vkládají. K tomu si budeš bohužel muset přečíst : \href{https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management}{tento článek:}, ale na druhou stranu, věř mi, že s přibývajícím zdroji se Ti to automatické generování stylu bude hodit. Citace pro \LaTeX Ti totiž umožní kde jaká slušná databáze, takže se Ti to ve výsledku všechno zjednoduší. Takže nějaké citace% \cite{einstein}. Nebo další \cite{dirac}.
\begin{figure}[ht!]
\centering
\includegraphics[width=110mm, cfbox = ukgray 1mm 0pt]{Auticko.png}
\caption{Autíčko s tlustým popiskem bez názvu kapitoly, netlustým textem a pojebkaným rámečkem okolo...\label{overflow}}
\end{figure}
Tady bude zase nějaká tabulka...\par
\begin{table}[htb]
\centering
\caption{Nějaká tabulka}
% \cfbox ukgray 1mm 0pt{
\begin{tabular}{r|r|r|r}
N & R & C & T \\ \hline % odd -- lightblue (wrong)
8 & 8 & 4 & 444 \\ % even
9 & 8 & 4 & 124 \\ % odd -- lightblue (wrong)
10 & 8 & 4 & 672 \\ % even
\end{tabular}
\end{table}
\section{Nadpis 2. úrovně}
\lipsum[2]
\lipsum
\section{Nadpis 2. úrovně}
\lipsum
\lipsum
\chapter{Seznam použitých zkratek a symbolů}
\chapter{Seznam použitých zdrojů}
\printbibliography
\end{document}
答案1
说实话,这是我见过的最糟糕的样式之一。它不仅不符合标准印刷惯例。它甚至不符合自己的惯例。它非常不一致、不平衡且令人分心。
但如果必须使用它,就必须使用它。我讨厌在 Word 中尝试这样做。即使在 LaTeX 中也没什么乐趣。
侧边线之所以延伸到纸张边缘,是因为它们占用了边注的空间宽度,但它们排版在文本块的另一侧,因此没有空间放置此类东西。我已经对内边距宽度进行了硬编码,但如果需要,您可以通过编程来选择它。边线的宽度存储在 中,
\siderulewidth
并设置为30mm
小于两倍\marginparsep
,徒劳地试图保持至少某种对称感。fancyhdr
提供宏来设置页脚和页头规则的偏移量。然后我们必须通过调整页眉和页脚内容的奇怪位置来进行补偿。我们用
etoolbox
它来修补\footrule
和\headrule
着色。配置
titlesec
被改变以使用\siderulewidth
并消除需要\dimexpr
,我们加载calc
。hyperref
需要最后加载。为了举例,
demo
使用并.bib
改变了,因为我没有原始指定的文件。
我认为,其结果是,在其笨拙的姿态中呈现出所期望的笨拙感。
代码以注释的形式包含一些额外的解释
\documentclass[a4paper,twoside, demo]{report}
\usepackage[top=3cm, bottom=3cm, inner=3cm, outer=3.5cm, headheight=18pt]{geometry}% 18pt is the minimum height required to accommodate the current header
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage[x11names,table]{xcolor}
\usepackage{graphicx}
\usepackage[strict]{changepage}
\usepackage{chngcntr}
\usepackage[export]{adjustbox}
\usepackage{fancyhdr}
\usepackage[explicit]{titlesec}
\usepackage[font={color=ukgray},figurename=Obr.,tablename=Tab.,labelfont={color=ukgray,bf}]{caption}
\usepackage{etoolbox,calc}
\usepackage{biblatex}
\usepackage{microtype}
\SetTracking[no ligatures={f}]{encoding=*}{80}
\usepackage{lipsum}
\usepackage{hyperref}% load last unless using cleveref or similar, which must be loaded right after
% BARVY
\definecolor{ukred}{RGB}{160,0,0}
\definecolor{ukgray}{RGB}{128,128,128}
\colorlet{ukredlight}{ukred!50}% not sure what this should be but presumably not identical to ukred - this makes mixes 50% ukred with 50% white
\definecolor{ukgraylight}{RGB}{192,192,192}
% TABULKY A OBRÁZKY
\counterwithout{figure}{chapter}
\captionsetup{justification = raggedright,singlelinecheck = false}
\counterwithout{table}{chapter}
\rowcolors{1}{ukgraylight}{white}
\renewcommand{\contentsname}{Obsah}
% This is the width of the side rules.
\newlength\siderulewidth
% The inner margin is 30mm.
% This subtracts twice the value of \marginparsep, so the side rules will be \marginparsep from the text block and from the edge of the paper.
% \marginparwidth isn't suitable here because we are setting the rules in the inner margin and not the outer one.
\setlength\siderulewidth{30mm-2\marginparsep}
% NUMBERS AND LINES for sectional divisions (NOT captions)
% chapters
\titleformat{\chapter}[hang]
{\bfseries\fontsize{14pt}{14pt}\selectfont\color{ukred}\lsstyle}
{\checkoddpage\ifoddpage\llap{\makebox[\marginparsep+\siderulewidth\relax][l]{\rule[-1.25ex]{\siderulewidth}{0.5ex}\llap{}}}\thechapter\enspace\else\thechapter\enspace \fi}
{0pt}
{\MakeUppercase{#1}\checkoddpage\ifoddpage\else\hfill\rlap{\makebox[\textwidth + \marginparsep][l]{\hspace{\marginparsep}\rlap{\rule[-1.25ex]{\siderulewidth}{0.5ex}}\thechapter}}\fi}%\titlerule[1.5pt]
\titlespacing*{\chapter}{0pt}{2ex}{1ex}
% sections
\titleformat{\section}
{\bfseries\large}
{\checkoddpage\ifoddpage\llap{\makebox[\marginparsep+\siderulewidth\relax][l]{\rule[-1.25ex]{\siderulewidth}{0.5ex}\llap{}}}\thesection\enspace\else\thesection\enspace \fi}
{0pt}
{#1\checkoddpage\ifoddpage\else\hfill\rlap{\makebox[\textwidth + \marginparsep][l]{\hspace{\marginparsep}\rlap{\smash{\rule[-1.25ex]{\siderulewidth}{0.5ex}}}\thesection}}\fi}%\titlerule[1.5pt]
\titlespacing*{\section}{0pt}{1ex}{0.5ex}
% subsections
\titleformat{\subsection}
{\bfseries}
{\checkoddpage\ifoddpage\llap{\makebox[\marginparsep+\siderulewidth\relax][l]{\rule[-1.25ex]{\siderulewidth}{0.5ex}\llap{}}}\thesubsection\enspace\else\thesubsection\enspace \fi}
{0pt}
{#1\checkoddpage\ifoddpage\else\hfill\rlap{\makebox[\textwidth + \marginparsep][l]{\hspace{\marginparsep}\rlap{\smash{\rule[-1.25ex]{\siderulewidth}{0.5ex}}}\thesubsection}}\fi} \titlespacing*{\subsection}{0pt}{1ex}{0.5ex}
% FOOTER / HEADER
\fancyhf{}
% NOTE: style is not even consistent!!
\fancyfoot[RE]{% on even pages, the footer is in the inner margin
\hspace*{\textwidth}%
\begin{minipage}{\siderulewidth+\marginparsep}%
\flushleft
\color{ukgraylight}%
\sffamily\small strana \\ \vspace{0.15cm} \textbf{\Large\thepage}%
\end{minipage}%
}
\fancyfoot[LO]{% on odd pages, the footer begins at the end of the inner margin
\hspace*{\dimexpr\siderulewidth+\marginparsep}%
\begin{minipage}{\textwidth}%
\flushleft
\color{ukgraylight}%
\sffamily\small strana \\ \vspace{0.15cm} \textbf{\Large\thepage}%
\end{minipage}%
}
% header always goes on the left, regardless of page, but we need to account for the offset on odd pages
\fancyhf[loh]{\hspace*{\dimexpr\siderulewidth+\marginparsep}\color{ukgraylight}\Large\sffamily\MakeUppercase{\leftmark}}
\fancyhf[leh]{\color{ukgraylight}\Large\sffamily\MakeUppercase{\leftmark}}
% presumably these are meant to be the same
\renewcommand*\footrulewidth{2.84pt}
\renewcommand*\headrulewidth{2.84pt}
% set the offset for head and foot rules
\fancyheadoffset[ref,lof]{\marginparsep+\siderulewidth}
\makeatletter
% add colours for head and foot rules
\patchcmd{\footrule}{\hrule\@width}{\color{ukgraylight}\hrule\@width}{\typeout{footrule patched OK!}}{\typeout{Oh, no! Could not patch footrule.}}
\patchcmd{\headrule}{\hrule\@height}{\color{ukredlight}\hrule\@height}{\typeout{headrule patched OK!}}{\typeout{Oh, no! Could not patch headrule.}}
% abolish differences between plain and regular page styles
\let\ps@plain\ps@fancy
\makeatother
\pagestyle{fancy}
% we don't want numbers in the headers; we don't want section or subsections - just always the chapter name, so mark everything this way
\renewcommand{\chaptermark}[1]{% p.10 manual
\markboth{#1}{}}
% CITACE
\addbibresource{biblatex-examples.bib}
\begin{document}
\tableofcontents
\chapter{Nadpis 1. úrovně}
\lipsum[1]
\section{Nadpis 2. úrovně}
\lipsum[2]
\subsection{Nadpis 3. úrovně}
\lipsum[3]
\chapter{První kapitola dizertace}
\lipsum[1]\par
Tady odcitujeme nějaký zdroj, ať víš, jak se vkládají. K tomu si budeš bohužel muset přečíst : \href{https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management}{tento článek:}, ale na druhou stranu, věř mi, že s přibývajícím zdroji se Ti to automatické generování stylu bude hodit. Citace pro \LaTeX Ti totiž umožní kde jaká slušná databáze, takže se Ti to ve výsledku všechno zjednoduší. Takže nějaké citace% \cite{einstein}. Nebo další \cite{dirac}.
\begin{figure}[ht!]
\centering
\includegraphics[width=110mm, cfbox = ukgray 1mm 0pt]{Auticko.png}
\caption{Autíčko s tlustým popiskem bez názvu kapitoly, netlustým textem a pojebkaným rámečkem okolo...\label{overflow}}
\end{figure}
Tady bude zase nějaká tabulka...\par
\begin{table}[htb]
\centering
\caption{Nějaká tabulka}
% \cfbox ukgray 1mm 0pt{
\begin{tabular}{r|r|r|r}
N & R & C & T \\ \hline % odd -- lightblue (wrong)
8 & 8 & 4 & 444 \\ % even
9 & 8 & 4 & 124 \\ % odd -- lightblue (wrong)
10 & 8 & 4 & 672 \\ % even
\end{tabular}
\end{table}
\section{Nadpis 2. úrovně}
\lipsum[2]
\lipsum
\section{Nadpis 2. úrovně}
\lipsum
\lipsum
\chapter{Seznam použitých zkratek a symbolů}
\chapter{Seznam použitých zdrojů}
\printbibliography
\end{document}