如何修复页边距中出现的以下重叠?我希望数字之间用逗号隔开。
编辑:澄清问题。文本需要从一行流到下一行,并在页边空白处标注章节编号。但是,当页边空白处同一行有两个或多个编号时,它们应该用逗号分隔或放在一个(略微)上方。
梅威瑟:
\documentclass{article}
\newcommand{\marginsec}[1]{%
\refstepcounter{marginsec}%
\mbox{\strut#1}\vadjust{\vbox to 0pt{
\sbox0{\bfseries\themarginsec\quad}
\kern-\ht0
\kern-\dp\strutbox
\llap{\box0 }
\vfill
}
}%
}
\newcounter{marginsec}
\begin{document}
\marginsec{Babel} and hyphenation patterns for english, dumylang, nohyphenation,
\marginsec{CATALAN}, pinyin, coptic, croatian, czech, danish, dutch, ukenglish,
usenglishmax, esperanto, estonian
\end{document}
编辑4:更清晰的解释:
这就是圣经中诗句的表达方式。由于我们手稿中的圣经文本基本上都是用原文字母背对背书写的,因此我们采用了章节和诗句的方法,使其更易读,也更容易引用文本中的某一点。
你有 66 本书,每本书分为多个章节。每章又分为许多节。
我需要对经文进行编号的方式是使用章节号作为第一节经文的编号。请参见下面创世纪第 1 章和第 2 章的两张屏幕截图。经文的编号随后不断增加,直到您到达下一章。
翻到下一章开始的第 3 页,它应该是这样的:
但根据马克的出色解决方案,下面所有的诗句编号和章节编号仍然显示出来,结果如下:
并且:
以下是重现我目前情况的示例。但是您可能没有嵌入的图像文件,因此只需删除标签中的代码即可wrapfigure
。
编辑5:这是我的文件。 演示文件
答案1
下面的方法可以解决问题(自从第一次提交以来,我已经解决了一个问题)。解决方案需要运行两次。第一次运行会保存标签编号,第二次运行会收集标签编号并将其转换为边距中的文本。
pdftex
在需要最新扩展\pdfsavepos
和的解决方案中pdflastypos
,我使用当前页码和 y 位置对应作为标签的数字进行分组。由于数字都是连续的,我决定对数字进行排版,以防<start>--<end>
数字范围过大。如果您确实想要一个逗号分隔的列表,那么这个问题应该很容易解决。
实现需要两个临时文件,因为一个文件必须存储计数器,这需要立即数\write
,另一个文件必须存储\pdflastypos
值,这些值只有在页面发送时才知道。我花了一段时间才明白其中的含义:-)
以下是包裹。 这输入基于McGafter
的输入。我没有 Caslon,因此必须重新定义页面标题(我不想费心定义它们)。
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mvd-verse}[2012/01/23 Marc van Dongen's verse numbering style]
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \msec@chapt is the number of the current chapter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\msec@chapt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \msec@verse is the number of the current verse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\msec@verse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \msec@calls is the number of calls to \marginsec
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\msec@calls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \msec@reads is the number of lines read from input files
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\msec@reads
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Option parsing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{pgfopts}
\pgfkeys{/mvdsec@package/initial/.style={/mvdsec/.cd,chapter=#1},
/mvdsec/.cd,
set verse/.code={\global\msec@verse=#1\relax},
set chapter/.code={\global\msec@chapt=#1\relax},
reset verse/.style={set verse=0},
chapter/.style={set chapter=#1,reset verse},
step chapter/.code={\global\advance\msec@chapt by 1\relax},
next chapter/.style={step chapter,reset verse},
/mvdsec@package/initial=1}
\ProcessPgfPackageOptions{/mvdsec@package}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Saving the y positions.
% This code is partially based on V{\'\i}t Z{\'y}ka's article in
% TUGboat, Volume 30 (2009), No. 1, pp.~123--124.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AtBeginDocument{%
\makeatletter
\newwrite\msec@numbers@output%
\newwrite\msec@ypos@output%
\immediate\openout\msec@numbers@output \msec@nmbr@file%
\openout\msec@ypos@output \msec@ypos@file%
\makeatother
}
\AtEndDocument{%
\immediate\closeout\msec@numbers@output%
\closeout\msec@ypos@output%
}
% Write the position to file.
% #1 is the page number
% #2 is the chapter number
% #3 is the verse number
\def\msec@write@lines#1#2#3{%
\pdfsavepos%
\immediate%
\write\msec@numbers@output{%
\string\msec@def@numbers%
\string{#1\string}%
\string{#2\string}%
\string{#3\string}%
}%
\write\msec@ypos@output{%
\string\msec@def@ypos\string{\the\pdflastypos\string}%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Read in the input files.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@ypos@file{\jobname.mpy}
\def\msec@nmbr@file{\jobname.mpn}
\def\msec@read@input@files{%
% keep changes and definitions local
\begingroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@text{-}
\def\msec@first{-}
\def\msec@chapter{-}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Evaluate lines read from input files.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@evaluate@lines{%
\msec@tmp@a%
\msec@tmp@b%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define next page, chapter, and verse.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@def@numbers##1##2##3{%
\def\msec@page{##1}%
\def\msec@chap{##2}%
\def\msec@vrse{##3}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define next y-position.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@def@ypos##1{%
\def\msec@ypos{##1}%
\edef\msec@next@py{\msec@page-##1}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Process next two input lines.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@read@lines{%
\msec@evaluate@lines%
\advance\msec@reads by 1\relax%
\ifx\msec@next@py\msec@curr@py%
\edef\msec@text{\msec@first--\msec@vrse}%
\else%
\edef\msec@READS{\the\msec@reads}
\ifx\msec@chap\msec@chapter%
\edef\msec@text{\msec@vrse}%
\edef\msec@first{\msec@vrse}
\else%
\edef\msec@chapter{\msec@chap}%
\edef\msec@text{[\msec@chap}%
\edef\msec@first{[\msec@chap}
\fi%
\edef\msec@curr@py{\msec@next@py}%
\fi%
\expandafter%
\xdef\csname msec@label@\msec@READS\endcsname{%
\msec@text%
}%
}
% end of local macro definitions
\def\msec@curr@py{0-0}% page-ypos
\msec@verse=0\relax%
\newread\msec@numbers@input
\newread\msec@ypos@input
\openin\msec@numbers@input \msec@nmbr@file%
\openin\msec@ypos@input \msec@ypos@file%
\loop%
\read\msec@numbers@input to \msec@tmp@a%
\read\msec@ypos@input to \msec@tmp@b%
\unless\ifeof\msec@numbers@input
\msec@read@lines
\repeat
\closein\msec@numbers@input%
\closein\msec@ypos@input%
\global\msec@reads=\msec@reads\relax%
\endgroup
}
\IfFileExists{\msec@ypos@file}
{\msec@read@input@files}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\msec@set@box{%
\@ifnextchar[%
\msec@set@chapter@box%
\msec@set@section@box%
}
\def\msec@set@chapter@box[#1\msec@set@box{%
\msec@set@chapter@box@#1--\msec@set@box%
}
\def\msec@set@chapter@box@#1--#2\msec@set@box{%
\textbf{#1}%
}
\def\msec@set@section@box#1\msec@set@box{%
#1%
}
\newcommand{\marginsec}[2][]{%
\strut\nobreak#2%
\pgfkeys{/mvdsec/.cd,#1}%
\advance\msec@calls by 1\relax%
\advance\msec@verse by 1\relax%
\ifnum\msec@reads<\msec@calls%
\def\msec@tmp{}%
\else%
\edef\msec@tmp{\csname msec@label@\the\msec@calls\endcsname}%
\fi%
\msec@write@lines{\thepage}{\the\msec@chapt}{\the\msec@verse}%
\vadjust{\vbox to 0pt{%
\sbox0{\expandafter\msec@set@box\msec@tmp\msec@set@box\quad}
\kern-\ht0
\kern-\dp\strutbox
\llap{\box0 }
\vfill
}
}%
}
\newcommand{\getChapter}{\the\msec@chapt}
\newcommand{\getVerse}{\the\msec@verse}
\makeatother
以下是示例输入。它基于McGafter
的输入。
\documentclass[pagesize=pdftex, 9pt]{scrbook}
\usepackage[pagestyles]{titlesec}
\usepackage{geometry}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage{wrapfig}
% \usepackage[initial=4]{mvd-verse} starts with chapter 4.
\usepackage{mvd-verse}
\geometry{
paperwidth=15.3cm,
paperheight=23.2cm,
top=1.5cm,
bottom=.8cm,
left=1.3cm,
right=1.3cm
}
% sets font to use
% package = xltxtra
\defaultfontfeatures{Mapping=tex-text}
% Don't have Cardo
%\setmainfont{Cardo}
\newpagestyle{Biblestyle}{
\setheadrule{.02pt}
\sethead[\thepage][\chaptertitle]%
[you have to fix this]%
{THIS TOO}%
{\chaptertitle}{\thepage}
}
% Paragraph formatting
\setlength{\parindent}{0pt}
% sets the marks to be used (section and subsection)
\setmarks{section}{subsection}
\newlength\howwide
\newcommand\defhowwide{
\ifnumless{\value{section}}{99}{\ifnumgreater{\value{section}}{8}{\setlength{\howwide}{2.5em}}{\setlength{\howwide}{1.2em}}}{\ifnumgreater{\value{section}}{98}{\setlength{\howwide}{3.5em}}{\setlength{\howwide}{2.5em}}}
}
% the ratio of the embedded PDF to the text on the page
\newlength\ratiowidth
\setlength\ratiowidth{.62\textwidth}
\usepackage{hyperref}
\hypersetup{
bookmarksnumbered=true,
bookmarksopen=true,
bookmarksopenlevel=0,
bookmarksdepth=1,
unicode=true,
colorlinks=true,
citecolor={black},
linkcolor={black},
urlcolor={black},
pdffitwindow=true,
pdftitle={The Holy Bible}
}
\begin{document}
\mainmatter
\pagestyle{Biblestyle}
\begin{wrapfigure}{r}{\ratiowidth}
\begin{center}
\includegraphics[width=\ratiowidth, page=1, trim=70 50 85 30, clip]{torahCropped.pdf}
\end{center}
\end{wrapfigure}
\phantomsection
\addcontentsline{toc}{part}{Law}\noindent
\phantomsection
\addcontentsline{toc}{chapter}{Genesis}\noindent
\small{THE FIRST BOOK OF MOSES, CALLED\\
\textbf{\LARGE{GENESIS}}\\
}
\normalsize
\marginsec{In} the beginning God created the heaven and the earth.
\marginsec{And} the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
\marginsec{And} God said, Let there be light: and there was light.
\marginsec{And} God saw the light, that it was good: and God divided the light from the darkness.
\marginsec{And} God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.
\marginsec{And} God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.
\marginsec{And} God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.
\marginsec{And} God called the firmament Heaven. And the evening and the morning were the second day.
\marginsec{And} God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.
\marginsec{And} God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.
\marginsec{And} God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.
\marginsec{And} the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.
\marginsec{And} the evening and the morning were the third day.
\clearpage
\begin{wrapfigure}{r}{\ratiowidth}
\begin{center}
\includegraphics[width=\ratiowidth, page=2, trim=70 50 85 30, clip]{torahCropped.pdf}
\end{center}
\end{wrapfigure}
\marginsec{And} God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:
\marginsec{And} let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.
\marginsec{And} God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.
\marginsec{And} God set them in the firmament of the heaven to give light upon the earth,
\marginsec{And} to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.
\marginsec{And} the evening and the morning were the fourth day.
\marginsec{And} God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.
\marginsec{And} God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.
\marginsec{And} God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.
\marginsec{And} the evening and the morning were the fifth day.
\marginsec{And} God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.
\marginsec{And} God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good.
\marginsec{And} God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.
\marginsec{So} God created man in his own image, in the image of God created he him; male and female created he them.
\marginsec{And} God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing
\clearpage
\begin{wrapfigure}{r}{\ratiowidth}
\begin{center}
\includegraphics[width=\ratiowidth, page=3, trim=70 50 85 30, clip]{torahCropped.pdf}
\end{center}
\end{wrapfigure}
that moveth upon the earth.
\marginsec{And} God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat.
\marginsec{And} to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so.
\marginsec{And} God saw every thing that he had made, and, behold, it was very good. And the evening and the morning were the sixth day.
\marginsec[next chapter]{Thus} the heavens and the earth were finished, and all the host of them.
\marginsec{And} on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.
\marginsec{And} God blessed the seventh day, and sanctified it: because that in it he had rested from all his work which God created and made.
\marginsec{These} are the generations of the heavens and of the earth when they were created, in the day that the LORD God made the earth and the heavens,
\marginsec{And} every plant of the field before it was in the earth, and every herb of the field before it grew: for the LORD God had not caused it to rain upon the earth, and there was not a man to till the ground.
\marginsec{But} there went up a mist from the earth, and watered the whole face of the ground.
\marginsec{And} the LORD God formed man of the dust of the ground, and breathed into his nostrils the breath of life; and man became a living soul.
\marginsec{And} the LORD God planted a garden eastward in Eden; and there he put the man whom he had formed.
\marginsec{And} a short TEST VERSE.
\marginsec{And} out of the ground made the LORD God to grow every tree that is pleasant to the sight, and good for food; the tree of life also in the midst of the garden, and the tree of knowledge of good and evil.
\marginsec{And} a river went out of Eden to water the garden; and from thence it was parted, and became into four heads.
\marginsec{The} name of the first is Pison: that is it which compasseth the whole land of Havilah, where
\marginsec[chapter=22]{And} we're almost there.
\marginsec[next chapter]{I} promise; I really do.
\marginsec{For} we cannot go on forever.
\marginsec{We} have to stop somewhere or we'll never stop.
\marginsec{Bye} now.
Finally, the current chapter and verse are \getChapter\ and \getVerse.
\end{document}
答案2
我不确定我是否正确解释了这个问题,但这里有一个 MWE。如果您愿意将诗句包含在环境中,则可以修改宏以提供更复杂的排版方式。
\documentclass{article}
\usepackage{xspace,lineno}
\newcounter{ctr}
\setcounter{ctr}{0}
\makeatletter
\def\inc{\refstepcounter{ctr}\thectr}
\def\collect{}
\def\typeset{\marginpar{\collect}\let\collect\@empty\space}
\def\verse{%
\ifx\collect\@empty
\g@addto@macro{\collect}{\inc}\footnotemark
\else
\g@addto@macro{\collect}{,\inc }\footnotemark
\fi
}
\let\endverses\typeset
\begin{document}
When you decided to produce your publication you have accepted the will to learn enough of a system to do your own work, but this now involves more than the art of the typesetter. You need to invest time to learn the programming part of packages and LaTeX and programming needs artful and other skills.\verse
\endverses
There are no-shortcuts and instant solutions\verse. No magic wands. You need to invest time in effortful study. \verse There are no-shortcuts and instant solutions. No magic wands.\verse You need to invest time in effortful study.\verse
\endverses
\end{document}
输出
如果可以在环境中用一组诗句括住段落,则可以将行号定位在实际的行上,因为这将能够vsplit
实现。