LaTeX:在页边空白处排版章节号
我正在尝试用 LaTeX 排版一些东西,我想知道我做得是否正确。基本思想是节号挂在左边距。对于章节标题,该数字采用标题高度+2 行,对于节标题,该数字采用+1 行,并且与小节的标题高度相同,并与标题顶部对齐。请参阅下图以了解我在说什么:
http://img62.imageshack.us/ img62/8404/bladld.png
我的方法是使用 titlesec
并执行以下操作:
\titleformat{\chapter}%
{\Huge\bfseries\sffamily}% format
{\vbox to 16pt{\llap{% label
\fontsize{3em}{0}\selectfont{\thechapter}%
\hskip 9pt%
}}}%
{0pt}% horizontal sep
{}% before
\titlespacing*{\chapter}%
{0pt}% left
{-2em}% before
{0pt}% after
但是这个解决方案有一些我宁愿避免的黑客行为。例如,\vbox
高度是通过反复试验找到的。从视觉上看,它看起来几乎是正确的......
I'm trying to typeset something in LaTeX and I would like to know if I'm doing it right. The basic idea is that section number hangs in the left margin. The number takes the height of the header+2 lines for a chapter heading, +1 line for section heading, and has the same height as the header for subsections, and is aligned to the top of the heading. See the following image to get an idea of what I'm talking about:
http://img62.imageshack.us/img62/8404/bladld.png
My approach is using titlesec
and doing something like this:
\titleformat{\chapter}%
{\Huge\bfseries\sffamily}% format
{\vbox to 16pt{\llap{% label
\fontsize{3em}{0}\selectfont{\thechapter}%
\hskip 9pt%
}}}%
{0pt}% horizontal sep
{}% before
\titlespacing*{\chapter}%
{0pt}% left
{-2em}% before
{0pt}% after
But this solution has some hacks that I would rather avoid. The \vbox
height for instance, is found by trial and error. Visually, it looks almost right...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用回忆录文档类。有大量选项可以完成此类操作,而且更加简洁...
有一个
hangnum
样式,对于部分,有一个\hangsecnum
选项,但是这只会将数字放在边距中:它不会使其变大。回忆录也有精彩的记录。所以我希望你需要的一切都会在那里。 Hangnum 的代码位于精彩的 回忆录手册。因此,从那里和后面的示例中,您应该获得获得所需内容所需的所有指示......Try using the memoir document class. That has a ton of options for doing exactly this kind of thing, and it's much neater...
There's a
hangnum
style and for sections, there's a\hangsecnum
option, but that only puts the number in the margin: it doesn't make it bigger. Memoir is also fabulously documented. So I expect all everything you need will be there. The code for hangnum is on p.88 of the fantastic memoir manual. So from there and from later examples you should get all the pointers you need to get what you want...