常见的做法是将一部老戏剧(例如莎士比亚)的注释放在左页,将参考资料放在右页。我不想对戏剧这样做,但我想将一份文档的注释放在一页,将文本放在对页。
问题在于我想要确保注释具有平行的节间距,因为注释的长度可能比文档中相应的节更长或更短,而且我不希望让您必须在文档之间来回切换。
也就是说,我希望它是这样的:
+-----------------+ +-----------------+
| Heading | | Heading |
| ------- | | ------- |
| annotation | | this paragraph |
| | | is long |
| | | |
| Heading 2 | | Heading 2 |
| --------- | | --------- |
| this annotation | | short paragraph |
| is really long | | |
+-----------------+ +-----------------+
是否有人知道可以做到这一点的软件包,或者有其他方法可以实现排列文档和注释的目标?
答案1
CTAN 中有一些包有并行文本,通常以列的形式。您可以在www.ctan.org/topic/parallel。
第一个例子使用parallel
包中只有平行的列:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{parallel}
\usepackage{lipsum} % dummy text
\title{Parallel columns}
\author{You}
\begin{document}
\maketitle
\begin{Parallel}{.45\textwidth}{.45\textwidth}
\ParallelLText{\section{Heading\label{h}} \lipsum[1]}
\ParallelRText{\section*{Notes to heading \ref{h}} \lipsum[2]}
\end{Parallel}
\ParallelPar
\begin{Parallel}{.45\textwidth}{.45\textwidth}
\ParallelLText{\section{Heading 2\label{h2}} \lipsum[3]}
\ParallelRText{\section*{Notes to heading \ref{h2}} \lipsum[3]}
\end{Parallel}
\end{document}
[p]
您可以在对开页中转换此内容,只需在环境中添加选项即可Parallel
(当然,还要修改列的宽度),但环境的末尾会\ParallelPar
产生页面更改(每个页面\Parallel...Text
都填满一整页)。 下一个示例显示了问题:
\documentclass{article}
\usepackage[margin=4cm]{geometry}
\usepackage{parallel}
\usepackage{lipsum} % dummy text
\title{Facing pages}
\author{You}
\begin{document}
\maketitle
\begin{Parallel}[p]{\textwidth}{\textwidth}
\ParallelLText{\section{Heading One \label{h1}} \lipsum[1]}
\ParallelRText{\section*{Notes to heading \ref{h1}} \lipsum[2]}
\ParallelPar
\ParallelLText{\section{Heading One \label{h2}} \lipsum[1]}
\ParallelRText{\section*{Notes to heading \ref{h2}} \lipsum[2]}
\end{Parallel}
\begin{Parallel}[p]{\textwidth}{\textwidth}
\ParallelLText{\section{Heading One \label{h3}} \lipsum[1]}
\ParallelRText{\section*{Notes to heading \ref{h3}} \lipsum[2]}
\end{Parallel}
\end{document}
编辑
一个完全不同的方法是使用包手动设置偶数页中每个文本块的垂直位置texpos
。使用宏来处理每对块的同步性可以大大简化反复试验。必须检查块之间是否有一些间隔,以及每页的最后一个块是否延伸到下边距,但这可以通过选项showboxes
和showframes
包轻松检查。例如:
\documentclass[a4paper,twoside]{article}
\usepackage{afterpage}
% \usepackage{showframe} only for check block positions
\usepackage[margin=3cm]{geometry}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{textpos} % use "showboxes" for check results
\setlength{\TPHorizModule}{.1\textwidth} % = 10% width
\setlength{\TPVertModule}{.01\textheight}% = 01% height
% Facing Double Block Macro
% Usage:
% \FDB{position}{section}{even text}{odd text}
% position = a number between 0 to 100 (or some less)
\newcommand\FDB[4]{
\begin{textblock}{10}(0,#1)
%\textblockcolour{cyan!10} % ugly, only for testing
\section{#2\label{#2}} #3 \bigskip
\end{textblock}
\afterpage{
\begin{textblock}{10}(0,#1)
% \textblockcolour{green!10} % ugly, only for testing
\section*{Annonations about section \ref{#2}}
#4\bigskip
\end{textblock}}}
\title{Facing pages with
\texttt{texdoc} and \texttt{afterpage}}
\author{You}
\begin{document}
\maketitle
\newpage
\FDB{0}{A title}{\lipsum[1]}{\lipsum[2]}
\FDB{25}{Another title}{\lipsum[3]}{\lipsum[4-5]}
\FDB{56}{One more title}{\lipsum[5]}{\lipsum[6]}
\FDB{78}{The last title of this page}{\lipsum[7]}{\lipsum[8]}
\newpage
% Annotations will be here
\newpage
\FDB{1}{The title of a newpage}{\lipsum[9]}{\lipsum[10]}
\end{document}
答案2
这是使用该flowfram
包的另一种可能性。它计算页面上是否有足够的空间,这样您就不需要手动插入分页符了。
\documentclass[12pt]{scrbook}
\usepackage{flowfram}
\usepackage{lipsum}
\usepackage{etoolbox}
% set up frames
\newflowframe{\textwidth}{\textheight}{0pt}{0pt}[main]
\newdynamicframe[odd]{\textwidth}{\textheight}{0pt}{0pt}[details]
\newdynamicframe[even]{\textwidth}{\textheight}{0pt}{0pt}[annote]
% \checkisroom{idl}{text}
\makeatletter
\providecommand{\@gobblethree}[3]{}
\newsavebox\tmpsbox
\newif\ifenoughroom
\newcommand{\checkisroom}[2]{%
\bgroup
% get the frame's idn (stored in \ff@id)
\@dynamicframeid{#1}%
% temporarily suspend writing to external files
\let\protected@write\@gobblethree
% put the frame's contents and the pending text into
% the temporary sbox
\begin{lrbox}{\tmpsbox}%
\begin{minipage}{\textwidth}%
\csname @dynamicframe@\romannumeral\ff@id\endcsname
\par
#2%
\end{minipage}
\end{lrbox}%
% Does it fit the page?
\settoheight{\@ff@tmp@y}{\usebox\tmpsbox}%
\settodepth{\dimen@ii}{\usebox\tmpsbox}%
\addtolength{\@ff@tmp@y}{\dimen@ii}%
\ifdim\@ff@tmp@y>\textheight
\global\enoughroomfalse
\else
\global\enoughroomtrue
\fi
\egroup
}
% \getcontentsheight{length}{text}
\newcommand{\getcontentsheight}[2]{%
\bgroup
\let\protected@write\@gobblethree
\begin{lrbox}{\tmpsbox}%
\begin{minipage}{\textwidth}%
#2%
\end{minipage}%
\end{lrbox}%
\settoheight{\@ff@tmp@y}{\usebox\tmpsbox}%
\settodepth{\dimen@ii}{\usebox\tmpsbox}%
\addtolength{\@ff@tmp@y}{\dimen@ii}%
\global#1=\@ff@tmp@y\relax
\egroup
}
\newcounter{heading}
% \heading{label}{title}
\newcommand{\heading}[2]{%
\refstepcounter{heading}%
\label{#1}%
\markboth{#2}{#2}%
\annote
{%
\section*{\ref{#1}. #2}%
}%
{%
\section*{\ref{#1}. #2}%
\addcontentsline{toc}{section}{#2}%
\par\strut
}%
\afterheadingtrue
}
\newif\ifafterheading
\newlength\blockheight
\newcommand{\blocksep}{\par\vspace{2ex}}
% \annote{annotation}{text}
\newcommand{\annote}[2]{%
\getcontentsheight{\blockheight}{#1}%
\def\largerblock{#1}%
\getcontentsheight{\@ff@tmp@y}{#2}%
\ifdim\blockheight<\@ff@tmp@y
\blockheight=\@ff@tmp@y\relax
\def\largerblock{#2}%
\fi
\ifafterheading
\edef\startblock{%
\noexpand\blocksep
\noexpand\begin{minipage}[t][\the\blockheight]{\the\textwidth}%
\noexpand\setlength{\noexpand\parindent}{\the\parindent}%
\noexpand\par\noexpand\noindent
}%
\afterheadingfalse
\else
\edef\startblock{%
\noexpand\begin{minipage}[t][\the\blockheight]{\the\textwidth}%
\noexpand\setlength{\noexpand\parindent}{\the\parindent}%
\noexpand\par\noexpand\indent
}%
\fi
\checkisroom{details}{\largerblock}%
\ifenoughroom
\@dynamicframeid{annote}%
\expandafter\appenddynamiccontents\expandafter\ff@id
\expandafter{%
\expandafter\blocksep
\startblock
#1%
\end{minipage}}%
\@dynamicframeid{details}%
\expandafter\appenddynamiccontents\expandafter\ff@id
\expandafter{%
\expandafter\blocksep
\startblock
#2%
\end{minipage}}%
\else
% output 2 pages
\cleartoeven
\@dynamicframeid{annote}%
\expandafter\setdynamiccontents\expandafter\ff@id
\expandafter{\startblock#1\end{minipage}}%
\@dynamicframeid{details}%
\expandafter\setdynamiccontents\expandafter\ff@id
\expandafter{\startblock#2\end{minipage}}%
\fi
}
\makeatother
\newcommand{\cleartoeven}{%
\ifthispageodd % KOMA command
{\newpage}%
{\mbox{}\newpage\mbox{}\newpage}%
}
\appto\tableofcontents{\cleartoeven}
\AtEndDocument{\cleartoeven}
\title{Sample Document}
\author{A.N. Other}
\begin{document}
\maketitle
\tableofcontents
\heading{sample}{Sample Heading}
\annote
{Annotation on the left}
{A longer paragraph on the right matching the annotation on the
left.
\lipsum[1]
}
\heading{sample2}{Another Sample Heading}
\annote
{\lipsum[2]}
{\lipsum[3]}
\annote
{Another annotation.}
{\lipsum[4]}
\annote
{\lipsum[5-6]}
{\lipsum[7]}
\end{document}
答案3
这里有一种方法,其思想是:
在 A3 纸上使用
multicol
,注释在右半部分,原文在左半部分然后
pdfpages
交替使用每张 A3 纸的两半来生成 A4 文档
但是,存在一个问题,即分页符不应该在环境中发生multicols
。我尝试让分页符最好出现在文本+注释对之前,并且确实在示例中有效。但我猜它通常很容易失败。或者,更好的方法是将每个分页符放在multicols
一个小页面中。这里需要使用真实源代码进行一些测试。
因此,我们有两个 tex 文件,我将第一个命名为 ,parallelin.tex
第二个命名为parallelout.tex
。pdftex
第一个在第一个上运行。然后在第二个中手动插入 A3 页面的数量(肯定有办法自动完成此操作)。然后第二个pdftex
在第二个上运行。这将生成一个带有标题页的 A4 文档,然后是所需的布局。
\documentclass[a3paper,landscape]{article}
\usepackage[margin=4cm,foot=2cm]{geometry}
\usepackage{multicol}
\usepackage{fancyhdr} % for page numbers in the footer
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
%% setting up the page numbers for the final document
\newcount\tmpcount
\makeatletter
\def\twicethepage{\tmpcount\c@page \multiply\tmpcount by 2 \the\tmpcount}
\def\twicethepageplusone{\tmpcount\c@page \multiply\tmpcount by 2
\advance\tmpcount by 1 \the\tmpcount}
\makeatother
\fancyhead{}
\fancyfoot{\hfill\hbox to 21cm{\makebox[0pt]{\twicethepage}\hss\makebox[0pt]{\twicethepageplusone}}\hfill}
\usepackage{lipsum} % dummy text
\begin{document}
%% setting up multicol
\setlength{\columnsep}{8cm} % twice the margin
\multicoltolerance\tolerance
\multicolpretolerance\pretolerance
\raggedcolumns
\begin{multicols}{2}
\section{Heading One \label{h1}} \lipsum[1]
\columnbreak
\section*{Notes to heading \ref{h1}} \lipsum[10]
\end{multicols}
\pagebreak[3]
\begin{multicols}{2}
\section{Heading Two \label{h2}} \lipsum[2-3]
\columnbreak
\section*{Notes to heading \ref{h2}} \lipsum[11]
\end{multicols}
\pagebreak[3]
\begin{multicols}{2}
\section{Heading Three \label{h3}} \lipsum[4]
\columnbreak
\section*{Notes to heading \ref{h3}} \lipsum[12-13]
\end{multicols}
\pagebreak[3]
\begin{multicols}{2}
\section{Heading Four \label{h4}} \lipsum[5-6-7]
\columnbreak
\section*{Notes to heading \ref{h4}} \lipsum[12]
\end{multicols}
\pagebreak[3]
\begin{multicols}{2}
\section{Heading Five \label{h5}} \lipsum[2-3]
\columnbreak
\section*{Notes to heading \ref{h5}} \lipsum[11]
\end{multicols}
\pagebreak[3]
\begin{multicols}{2}
\section{Heading Six \label{h6}} \lipsum[4]
\columnbreak
\section*{Notes to heading \ref{h6}} \lipsum[12-13]
\end{multicols}
\pagebreak[3]
\begin{multicols}{2}
\section{Heading Seven \label{h7}} \lipsum[5-6-7]
\columnbreak
\section*{Notes to heading \ref{h7}} \lipsum[12]
\end{multicols}
\end{document}
现在parallelout.tex
:
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\title{Parallel columns}
\author{Me}
\maketitle
\clearpage
\newcount\mycount
\advance\mycount1
\loop
\includepdf[noautoscale=true,offset=10.5cm 0cm,pages={\the\mycount}]{parallelin.pdf}%
\includepdf[noautoscale=true,offset=-10.5cm 0cm,pages={\the\mycount}]{parallelin.pdf}%
\ifnum\mycount<3 % <- put here the actual number of A3 pages of parallelin.pdf
\advance\mycount1
\repeat
\end{document}
我在这里展示第一步的输出,A3 页: