请参阅 MWE。第 1 页显示的文本带有边距注释,注释只有几行。我想要的是正文在边距注释下方展开。第 2 页的情况正好相反。在这种情况下,正文很短,边距注释应该在其下方展开。我将 MWE 保持在最低限度,但我添加了一张图片来显示我希望获得的布局。我尝试使用包 marginnote 和 change page 来实现这一点。希伯来语字符已通过 \wrapfigure 环境添加到正文中。还有可能使用内部边距注释来代替我示例中的标题。最后,我的目标是实现类似于经典 Vilna Talmud 布局的布局(参见https://www.sas.upenn.edu/~jtreat/rs/002/Judaism/talmud.html)。
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\scriptsize }
\renewcommand\raggedrightmarginnote{}
\renewcommand\raggedleftmarginnote{}
\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=7.5cm,
inner=2cm,
marginparwidth=2.5cm, marginparsep=0.5cm,
showframe]
{geometry}
\usepackage[strict]{changepage}
\usepackage{polyglossia}
\begin{document}
\sloppy
\paragraph*{First}
This
\marginnote{This is a small margin paragraph, way smaller that the text it comments.}
is a long text, way longer that the comment at its margin. So there is no need to keep the paragraph width as is but it can be expanded by 3 cm.
\begin{adjustwidth*}{}{-3cm}
\lipsum[1]
\end{adjustwidth*}
\newpage
\paragraph{First}
This
\marginnote{This is a long margin note. The text is small so the margin note can expand and take over all the space in the page. \lipsum[1]}
is a small paragraph that lasts only a few lines.
\end{document}
答案1
您可以使用一些算术来计算较短(按高度)文本需要缩进的行数,然后使用\hangindent
和\hangafter
排版较长的文本,并将较短的文本添加到框中:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=10.5cm,
inner=2cm,
showframe]
{geometry}
\def\divtrancate(#1/#2){%
\ifnum\numexpr #1 - #2*\numexpr #1/#2\relax<0
\the\numexpr #1/#2\relax\else\the\numexpr #1/#2+1\relax\fi
}
\newbox\mishna
\newbox\tosafot
\def\talmudlayout#1 #2\par#3\par{
\setbox\mishna\vbox{\hsize=7.5cm\relax\noindent\textbf{#1}.\hskip 1em\relax #2}
\setbox\tosafot\vbox{\hsize=2.5cm\relax\scriptsize\noindent #3\par}
\ifdim\ht\mishna>\ht\tosafot
\hangafter=-\divtrancate(\dimexpr\ht\tosafot\relax/\dimexpr\baselineskip\relax)
\hangindent=-3cm
\noindent
\vadjust{\moveright 8cm\vbox to 0pt{\vskip-.5\baselineskip\box\tosafot\vss}}%
\textbf{#1}.\hskip 1em\relax #2\par
\else
\hangafter=-\divtrancate(\dimexpr\ht\mishna\relax/\dimexpr 9.5pt\relax)
\hangindent=8cm
\noindent
\vadjust{\vbox to 0pt{\vskip-.5\baselineskip\box\mishna\vss}}%
{\scriptsize #3\par}
\fi
}
\begin{document}
\talmudlayout First
This is a long text, way longer than the comment at its margin.
So there is no need to keep the paragraph width as is but it can
be expanded by 3 cm. \lipsum[1]
This is a small margin paragraph, way smaller than the text it comments.
\newpage
\talmudlayout Second
This is a short text, way shorter than the comment at its margin.
So there is no need to keep the comment width as is but it can
be expanded by 8 cm.
This is a long margin paragraph, way longer than the text it comments.
\lipsum[1]
\end{document}
如果您想根据页码更改注释的一侧,就像 \marginnote 一样,只需在宏中添加另一个测试:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=10.5cm,
inner=2cm,
showframe]
{geometry}
\makeatletter
\newcommand*\writetalmudpage{%
\write\@auxout{%
\string\expandafter\gdef\string\csname\space talmudlayout@\thetalmudpage\string\endcsname{\thepage}}}
\makeatother
\newcommand*\defloop[1]{%
\expandafter\def\csname talmudlayout@#1\endcsname{0}
\ifnum#1<100
\expandafter\defloop
\expandafter{\number\numexpr#1+1\expandafter}%
\fi}
\defloop{1}
\def\divtrancate(#1/#2){%
\ifnum\numexpr #1 - #2*\numexpr #1/#2\relax<0
\the\numexpr #1/#2\relax\else\the\numexpr #1/#2+1\relax\fi
}
\newcounter{talmudpage}
\newbox\mishna
\newbox\tosafot
\def\talmudlayout#1 #2\par#3\par{
\stepcounter{talmudpage}
\setbox\mishna\vbox{\hsize=7.5cm\relax\noindent\textbf{#1}.\hskip 1em\relax #2}
\setbox\tosafot\vbox{\hsize=2.5cm\relax\scriptsize\noindent #3\par}
\ifdim\ht\mishna>\ht\tosafot
\hangafter=-\divtrancate(\dimexpr\ht\tosafot\relax/\dimexpr\baselineskip\relax)
\hangindent=\ifodd\csname talmudlayout@\thetalmudpage\endcsname -3cm\else 3cm\fi
\noindent\writetalmudpage
\vadjust{\ifodd\csname talmudlayout@\thetalmudpage\endcsname \moveright 8cm\fi\vbox to 0pt{\vskip-.5\baselineskip\box\tosafot\vss}}%
\textbf{#1}.\hskip 1em\relax #2\par
\else
\hangafter=-\divtrancate(\dimexpr\ht\mishna\relax/\dimexpr 9.5pt\relax)
\ifodd\csname talmudlayout@\thetalmudpage\endcsname \hangindent=8cm\else \hangindent=-8cm\fi
\noindent\writetalmudpage
\vadjust{\ifodd\csname talmudlayout@\thetalmudpage\endcsname\else \moveright 3cm\fi\vbox to 0pt{\vskip-.5\baselineskip\box\mishna\vss}}%
{\scriptsize #3\par}
\fi
}
\begin{document}
\sloppy
\talmudlayout First
This is a long text, way longer than the comment at its margin.
So there is no need to keep the paragraph width as is but it can
be expanded by 3 cm. \lipsum[1]
This is a small margin paragraph, way smaller than the text it comments.
\newpage
\talmudlayout Second
This is a long text, way longer than the comment at its margin.
So there is no need to keep the paragraph width as is but it can
be expanded by 3 cm. \lipsum[1]
This is a small margin paragraph, way smaller than the text it comments.
\newpage
\talmudlayout Third
This is a short text, way shorter than the comment at its margin.
So there is no need to keep the comment width as is but it can
be expanded by 8 cm.
This is a long margin paragraph, way longer than the text it comments.
\lipsum[1]
\newpage
\talmudlayout Fourth
This is a short text, way shorter than the comment at its margin.
So there is no need to keep the comment width as is but it can
be expanded by 8 cm.
This is a long margin paragraph, way longer than the text it comments.
\lipsum[1]
\end{document}
编辑
第二段代码有些问题,所以我修复了它。现在需要两次编译才能得到正确的结果。
至于评论中的问题,我认为制作一个包裹是这里最简单的事情。
将以下代码放入名为的文件中talmudlayout.sty
:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{talmudlayout}
\RequirePackage{xkeyval}
\RequirePackage{footnote}
\newlength\talmudlayout@mishna@width
\setlength\talmudlayout@mishna@width{.7\textwidth}
\newlength\talmudlayout@tosafot@width
\setlength\talmudlayout@tosafot@width{.25\textwidth}
\newlength\talmudlayout@mishnahead@hsep
\setlength\talmudlayout@mishnahead@hsep{.05\textwidth}
\newcommand*\talmudlayout@tosafot@size{scriptsize}
\newcommand*\talmudlayout@mishna@ext{0}
\newcommand*\talmudlayout@tosafot@ext{0}
\newcommand*\talmudlayout@mishnahead@ext{0}
\newcommand*\talmudlayout@max{30}
\DeclareOptionX{tosafot}{\renewcommand*\talmudlayout@tosafot@ext{#1}}
\DeclareOptionX{mishna}{\renewcommand*\talmudlayout@mishna@ext{#1}}
\DeclareOptionX{head}{\renewcommand*\talmudlayout@mishnahead@ext{#1}}
\DeclareOptionX{max}{\talmudlayout@max}
\DeclareOptionX{headsep}{\setlength\talmudlayout@mishnahead@hsep{#1}}
\DeclareOptionX{mishnawidth}{\setlength\talmudlayout@mishna@width{#1}}
\DeclareOptionX{tosafotwidth}{\setlength\talmudlayout@tosafot@width{#1}}
\DeclareOptionX{tosafotsize}{\renewcommand*\talmudlayout@tosafot@size{#1}}
\ProcessOptionsX\relax
\newif\if@talmudlyaout@headmax
\newcommand*\talmudlayout@savecounters{%
\begingroup
\def\@elt##1{%
\global\csname c@##1\endcsname\the\csname c@##1\endcsname}%
\xdef\@gtempa{%
\cl@@ckpt
\let\noexpand\talmudlayout@restorecounters\noexpand\@empty
}%
\endgroup
\let\talmudlayout@restorecounters\@gtempa
}
\newcommand*\talmudlayout@restorecounters{}
\let\talmudlayout@restorecounters\@empty
\newcommand*\talmudlayout@skip{}
{\csname \talmudlayout@tosafot@size\endcsname\xdef\talmudlayout@skip{\the\baselineskip}}
\newcommand*\write@talmudlayout@page{%
\write\@auxout{%
\string\expandafter\gdef\string\csname\space talmudlayout@\thetalmudlayout@page\string\endcsname{\thepage}}}
\newcommand*\talmudlayout@defloop[1]{%
\expandafter\def\csname talmudlayout@#1\endcsname{0}
\ifnum#1<\talmudlayout@max
\expandafter\talmudlayout@defloop
\expandafter{\number\numexpr#1+1\expandafter}%
\fi}
\talmudlayout@defloop{1}
\newcommand*\talmudlayout@exploop[3]{% #1 = start, #2 = max, #3 = min
\ifnum #1<\numexpr #3+1\relax
\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname
\dimexpr \wd\talmudlayout@mishnaheadh + \talmudlayout@mishnahead@hsep\relax
\dimexpr \talmudlayout@mishna@width - \wd\talmudlayout@mishnaheadh-\talmudlayout@mishnahead@hsep\relax
\else
\dimexpr \textwidth-\talmudlayout@mishna@width \relax
\dimexpr \talmudlayout@mishna@width - \wd\talmudlayout@mishnaheadh-\talmudlayout@mishnahead@hsep\relax
\fi
\else
\if@talmudlyaout@headmax
\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname
\dimexpr \wd\talmudlayout@mishnaheadh+\talmudlayout@mishnahead@hsep\relax
\dimexpr \textwidth-\wd\talmudlayout@mishnaheadh-\talmudlayout@mishnahead@hsep\relax
\else
\z@ \dimexpr\textwidth-\wd\talmudlayout@mishnaheadh-\talmudlayout@mishnahead@hsep\relax
\fi
\else
\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname
\z@ \dimexpr\talmudlayout@mishna@width\relax
\else
\dimexpr \textwidth-\talmudlayout@mishna@width \relax \talmudlayout@mishna@width
\fi
\fi
\fi
\ifnum#1<#2
\expandafter\talmudlayout@exploop
\expandafter{\the\numexpr#1+1\expandafter}%
\expandafter{\the\numexpr#2\expandafter}%
\expandafter{\the\numexpr#3\expandafter}%
\fi}
\newcommand*\talmudlayout@divtrancate[2]{%
\ifnum\numexpr #1 - #2*\numexpr #1/#2\relax<0
\the\numexpr #1/#2\relax\else\the\numexpr #1/#2+1\relax\fi
}
\newcommand*\talmudlayout@parshape[2]{
\ifnum #1 < #2
\@talmudlyaout@headmaxtrue
\parshape \numexpr #2+1\relax
\talmudlayout@exploop{1}{#2}{#1}
\else
\@talmudlyaout@headmaxfalse
\parshape \numexpr #1+1\relax
\talmudlayout@exploop{1}{#1}{#2}
\fi
\z@ \textwidth
}
\def\talmudlayout@mishna@box#1#2#3{\vbox{\hsize=\talmudlayout@mishna@width
\hangafter=-\numexpr\talmudlayout@divtrancate{\dimexpr\ht\talmudlayout@mishnaheadv\relax}{\dimexpr \baselineskip\relax}+\talmudlayout@mishnahead@ext\relax
\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname
\hangindent=\dimexpr \wd\talmudlayout@mishnaheadh + \talmudlayout@mishnahead@hsep\relax
\else
\hangindent=-\dimexpr \wd\talmudlayout@mishnaheadh + \talmudlayout@mishnahead@hsep\relax
\fi
\noindent
\vadjust{\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname\else \moveright \dimexpr \talmudlayout@mishna@width - \wd\talmudlayout@mishnaheadh\relax\fi
\vbox to 0pt{\vskip-.75\baselineskip\bfseries\fontsize{46pt}{46pt}\selectfont\noindent #1\vss}}%
\strut\textbf{#2}.\hskip 1em\relax #3}}
\newbox\talmudlayout@mishnaheadh
\newbox\talmudlayout@mishnaheadv
\newbox\talmudlayout@mishna
\newbox\talmudlayout@tosafot
\newcounter{talmudlayout@page}
\newcommand*\talmudlayout{}
\long\protected\def\talmudlayout#1 #2 #3\par#4\par{
\stepcounter{talmudlayout@page}
\talmudlayout@savecounters
\setbox\talmudlayout@mishnaheadh\hbox{\bfseries\fontsize{46pt}{46pt}\selectfont\noindent #1}
\talmudlayout@restorecounters\talmudlayout@savecounters
\setbox\talmudlayout@mishnaheadv\vbox{\bfseries\fontsize{46pt}{46pt}\selectfont\noindent #1}
\talmudlayout@restorecounters\talmudlayout@savecounters
\setbox\talmudlayout@mishna\talmudlayout@mishna@box{#1}{#2}{#3}
\talmudlayout@restorecounters\talmudlayout@savecounters
\setbox\talmudlayout@tosafot\vbox{\hsize=\talmudlayout@tosafot@width\csname \talmudlayout@tosafot@size\endcsname\noindent\strut #4\par}
\talmudlayout@restorecounters\savenotes
\ifdim\ht\talmudlayout@mishna>\ht\talmudlayout@tosafot
\talmudlayout@parshape{\numexpr\talmudlayout@divtrancate{\dimexpr\ht\talmudlayout@tosafot\relax}{\dimexpr \baselineskip\relax}+\talmudlayout@mishna@ext\relax}%
{\numexpr\talmudlayout@divtrancate{\dimexpr\ht\talmudlayout@mishnaheadv\relax}{\dimexpr \baselineskip\relax}+\talmudlayout@mishnahead@ext\relax}
\noindent\write@talmudlayout@page
\vadjust{\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname \moveright \dimexpr\textwidth-\talmudlayout@tosafot@width\relax\fi
\vbox to 0pt{\vskip-.75\baselineskip\vbox{\hsize=\talmudlayout@tosafot@width\csname \talmudlayout@tosafot@size\endcsname\noindent\strut #4\par}\vss}}%
\vadjust{\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname\else \moveright \dimexpr\textwidth-\wd\talmudlayout@mishnaheadh\relax\fi
\vbox to 0pt{\vskip-.75\baselineskip\bfseries\fontsize{46pt}{46pt}\selectfont\noindent #1\vss}}%
\strut\textbf{#2}.\hskip 1em\relax #3\par
\else
\hangafter=-\numexpr\talmudlayout@divtrancate{\dimexpr\ht\talmudlayout@mishna\relax}{\dimexpr \talmudlayout@skip\relax}+\talmudlayout@tosafot@ext\relax
\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname
\hangindent=\dimexpr\textwidth-\talmudlayout@tosafot@width
\else
\hangindent=-\dimexpr\textwidth-\talmudlayout@tosafot@width
\fi
\noindent\write@talmudlayout@page
\vadjust{\ifodd\csname talmudlayout@\thetalmudlayout@page\endcsname\else \moveright \dimexpr\textwidth-\talmudlayout@mishna@width\relax\fi
\vbox to 0pt{\vskip-\talmudlayout@skip\talmudlayout@mishna@box{#1}{#2}{#3}\vss}}%
{\csname \talmudlayout@tosafot@size\endcsname\strut #4\par}
\fi
\par
\spewnotes
}
\endinput
现在我想你想要一些类似于以下文档的东西
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=10.5cm,
inner=2cm]
{geometry}
\usepackage[
tosafot=1,
mishna=1,
head=1,
headsep=1cm,
mishnawidth=7.5cm,
tosafotwidth=2.5cm]
{talmudlayout}
\begin{document}
\sloppy
\talmudlayout Big First
This is a long text, way longer than the comment at its margin.
So there is no need to keep the paragraph width as is but it can
be expanded by 3 cm. \lipsum[1]
This is a small margin paragraph, way smaller than the text it comments.
\newpage
\talmudlayout Big Second
This is a long text, way longer than the comment at its margin.
So there is no need to keep the paragraph width as is but it can
be expanded by 3 cm. \lipsum[1]
This is a small margin paragraph, way smaller than the text it comments.
\newpage
\talmudlayout Big Third
This is a short text, way shorter than the comment at its margin.
So there is no need to keep the comment width as is but it can
be expanded by 8 cm.
This is a long margin paragraph, way longer than the text it comments.
\lipsum[1]
\newpage
\talmudlayout Big Fourth
This is a short text, way shorter than the comment at its margin.
So there is no need to keep the comment width as is but it can
be expanded by 8 cm.
This is a long margin paragraph, way longer than the text it comments.
\lipsum[1]
\end{document}
该包定义了一个名为的宏,\talmudlayout
它接受 4 个参数。
- 第一个是正文的头部,其后以空格分隔。
- 第二个是正文的第一个单词,以空格分隔。
- 第三个是正文,它以 分隔,
\par
因此,如果您希望此论点包含多个段落,则必须使用\endgraf
,或更改论点的分隔符。 - 第四行是边距文本,也是用 \par 分隔的,同样的备注也适用于他。
如果您发现语法不方便,请随意更改分隔符。
该套餐有 8 种选择。
tosafot
,head
并mishna
在指定部分下方添加额外的空格行(默认为 0)。mishnawidth
并tosafotwidth
控制主文本和“边距”文本的宽度(至少当它们重叠时,默认值为.7\textwidth
和.25\textwidth
)。headsep
是头部和正文之间的水平间距(默认为.05\textwidth
)。max
是文档中允许的最大布局数量(默认为30
)tosafotsize
是用于控制边距文本大小的命令大小的名称(默认为scriptsize
)。
此代码也需要两次编译。您可以随意更改选项的默认值,我并没有花太多心思考虑它们。
为了更好地对齐第一行,您需要调整我在代码中使用的一些长度,调整长度\vskip
最终可能会得到您想要的结果。
示例文件展示了布局的四种可能情况。
答案2
由于您想要的输出并不完全清楚,我只是从您的问题中猜测了一些内容。也许这就是您想要的风格(不一定是最好的方法,但可以使用您的 MWE 作为基础):
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\scriptsize }
\renewcommand\raggedrightmarginnote{}
\renewcommand\raggedleftmarginnote{}
\usepackage[fontsize=13pt]{fontsize}
\usepackage[
paperwidth=160mm,
paperheight=240mm,
textheight=18cm,
textwidth=7.5cm,
inner=2cm,
marginparwidth=5cm,
marginparsep=0.5cm,
showframe]
{geometry}
\usepackage[strict]{changepage}
\begin{document}
\sloppy
\paragraph{First}
\marginnote{%
\begin{adjustwidth*}{2.5cm}{}
This is a long margin note that takes over the whole page.
\end{adjustwidth*}
\lipsum[1]
}{} is a small paragraph that lasts only a few lines.
\end{document}
看起来像这样:
或者您确实想缩小边距inner
,这样marginparsep
文本区域就可以进一步向内移动,并且放大的部分marginnote
更接近文本的中间:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{marginnote}
\renewcommand*{\marginfont}{\scriptsize }
\renewcommand\raggedrightmarginnote{}
\renewcommand\raggedleftmarginnote{}
\usepackage[fontsize=13pt]{fontsize}
\usepackage[
paperwidth=160mm,
paperheight=240mm,
textheight=18cm,
textwidth=7.5cm,
inner=.5cm,
marginparwidth=2.5cm,
marginparsep=0.1cm,
showframe]
{geometry}
\usepackage[strict]{changepage}
\begin{document}
\sloppy
\paragraph{First}
\marginnote{This is a long margin note that takes over the all page.
\begin{adjustwidth*}{}{-8em} \lipsum[1]
\end{adjustwidth*}
}{} is a small paragraph that lasts only a few lines.
\end{document}
看起来像这样(但在我看来,真的很尴尬):
或者完全不同的东西,我无法从你的问题中猜出......;)