有没有类似于 tufte-book 的软件包?
使用\marginpar
,可以生成以下内容(默认),但我想要目标;即将页眉扩展到页边距。
最后,我想要生成如下定位的页眉。
答案1
如果我理解正确的话,您正在寻找一些代码来创建类似于 Tufte-LaTeX 文档类中的页眉。页眉显示页码和章节/节标题。在 Tufte-LaTeX 文档类中,页眉超出了正文块的范围,延伸到边注区域。
以下代码基于 Tufte-LaTeX 代码,使用常规 LaTeX 文档类(例如book
和article
)可实现相同效果。它可能适用于其他文档类,也可能不适用于memoir
。(如果不适用,您可能只需要调整长度的名称以匹配文档类使用的名称。逻辑应该保持相似。)
\documentclass{book}% or article
% The geometry package isn't required; it's just here to set the margins for
% this demonstration.
\usepackage{geometry}
\geometry{%showframe,% draws lines to show margins
%asymmetric,% if you want the margin notes to always appear on the right side of the page
% the following are the margins used by the Tufte-LaTeX document classes
letterpaper,
left=1in,
top=1in,
headsep=2\baselineskip,
textwidth=26pc,
marginparsep=2pc,
marginparwidth=12pc,
textheight=44\baselineskip,
headheight=\baselineskip
}
\usepackage{ifthen}% for the \ifthenelse macro
% The Tufte-style running heads are defined similarly to the macros below.
% These macros avoid using Tufte-specific code, but may still be overkill for a
% particular document class. (For example, they detect if you're in twoside
% mode and use different running heads based on that.
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter% so we can use macros with @ in their names
% Set the header/footer width to be the body text block plus the margin
% note area.
\newlength{\overhanglength}
\AtBeginDocument{%
% Calculate the amount to extend the running heads
\setlength{\overhanglength}{\marginparwidth}
\addtolength{\overhanglength}{\marginparsep}
% Set the running head offsets to the overhang length calculated above
\ifthenelse{\NOT\boolean{@mparswitch}\AND\boolean{@twoside}}
{\fancyhfoffset[RE,RO]{\overhanglength}}% asymmetric
{\fancyhfoffset[LE,RO]{\overhanglength}}% symmetric
}
% The running heads/feet don't have rules
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhf{} % clear any existing header and footer fields
% adjust the formatting code to suit your tastes here
\ifthenelse{\boolean{@twoside}}{%
\fancyhead[LE]{\thepage\quad\leftmark}%
\fancyhead[RO]{\rightmark\quad\thepage}%
}{%
\fancyhead[RE,RO]{\rightmark\quad\thepage}%
}
\makeatother% restore the original meaning of @
\usepackage{blindtext}% provides filler text
\begin{document}
\Blinddocument% filler text
\end{document}