更改标题中的文本垂直对齐方式

发布于 2024-10-16 01:59:28 字数 589 浏览 1 评论 0原文

我正在尝试制作一个带有大章节号的标题格式,然后带有标题名称的较小文本。以下代码主要满足我的要求:

\documentclass[12pt]{book}
\usepackage{fontspec}
\setromanfont[Mapping=tex-text]{Garamond}
\usepackage{titlesec}
\titleformat{\chapter}{\raggedright}
    {\fontsize{72pt}{72pt}\selectfont\thechapter}{1em}{\huge}

\begin{document}
\chapter{A Short Title}
Lorem ipsum...
\chapter{A Very Long Title With Extra Words}
Lorem ipsum...
\end{document}

但是,如果章节标题长于 1 行,则数字的垂直对齐方式会令人不快。我很乐意告诉数字垂直对齐,以便数字的顶部与行上其余文本的顶部匹配,而不是当前的对齐方式,其中数字的基线与基线对齐文本的其余部分。

我不知道什么命令可以使这成为可能 - 很可能有很多更好的方法来解决这个问题。

谢谢!

I'm trying to make a title format with a large chapter number, and then smaller text with the name of the title. The following code mostly does what I want:

\documentclass[12pt]{book}
\usepackage{fontspec}
\setromanfont[Mapping=tex-text]{Garamond}
\usepackage{titlesec}
\titleformat{\chapter}{\raggedright}
    {\fontsize{72pt}{72pt}\selectfont\thechapter}{1em}{\huge}

\begin{document}
\chapter{A Short Title}
Lorem ipsum...
\chapter{A Very Long Title With Extra Words}
Lorem ipsum...
\end{document}

However, if the chapter title is longer than 1 line, the vertical alignment of the numeral is unpleasant. I'd love to tell the numeral to be vertically aligned so that the top of the numeral matches the top of the rest of the text on the line, as opposed to the current alignment, where the baseline of the numeral is aligned with the baseline of the remainder of the text.

I don't know what command would make this possible - and it's probable that there are lots better ways of solving this problem.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-10-23 01:59:28

为了解决这个问题: tex.sx qn 有几种方法 标题中的垂直文本对齐,您接受的解决方案重新定义了 Latex 内部宏 \@makechapterhead 以在输出中布置章节标题;请注意,还有其他内部宏可以定义可在页眉/页脚中使用的文本或设置目录中的行,并且这些宏可以类似地重新定义。

回忆录类中的章节样式值得一看; Lars Maden 的公开 给出了内置于类,并展示如何定义一些替代方案,

For the sake of getting this question off unanswered: there are a couple of approaches on the tex.sx qn Vertical Text Alignment in Title, where the solution you accepted redefines the Latex internal macro \@makechapterhead to lay out the chapter heading in the output; note that there are other internal macros that either define the text that can be used in headers/footers or set the line in the TOC, and these can similarly be redefined.

It's worth looking at the chapter styles in the Memoir class; Lars Maden's expose gives the standard styles built into the class, and shows how you can define some alternatives,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文