Latex 中将换行符转换为空格

发布于 2024-09-26 16:37:18 字数 202 浏览 2 评论 0原文

我正在编写一份文档,并且有几个章节标题,我希望将其显示为两行章节标题,但在目录中仅显示一行。有没有一个简单的命令可以过滤掉这样的换行符?

章节标题

第一行:

第二行信息更丰富

ToC:

第一行:第二行提供更多信息

I'm writing a document and I have a few chapter titles that I would like to appear as 2 lines for a chapter title, but only one line in the table of contents. Is there a simple command I to filter out the newline character like this?

Chapter Title

First Line:

Second more informative line

ToC:

First Line: Second more informative line

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

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

发布评论

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

评论(2

ヤ经典坏疍 2024-10-03 16:37:18

您可以为目录定义替代章节标题:

\chapter[toc title]{regular title}

you can define alternative chapter titles for the toc:

\chapter[toc title]{regular title}
久光 2024-10-03 16:37:18

基于上面第二个答案——添加另一个答案,这样我就可以很好地格式化代码。

如果需要,您甚至可以发出自己的命令。像这样的事情:

\newcommand{\twolineChapter}[2]{ %
    \chapter[#1: #2]{#1: \\ #2} %
}

然后在文档正文中写入

\twolineChapter{First Line}{Second more informative line}

,当您排版书籍时,它会变成这样,

\chapter[First Line: Second more informative line]{First Line: \\ Second more informative line}

如果您后来决定更改标题的格式(例如将副标题设置为较小的字体),这尤其好。

Building on second's answer above -- adding another answer so I can format the code nicely.

If you want, you can even make your own command. Something like this:

\newcommand{\twolineChapter}[2]{ %
    \chapter[#1: #2]{#1: \\ #2} %
}

Then write in your document's body

\twolineChapter{First Line}{Second more informative line}

Which, when you typeset your book, will get turned into

\chapter[First Line: Second more informative line]{First Line: \\ Second more informative line}

This is especially nice if you later decide to change how titles are formatted, for example putting the subtitle in a smaller font.

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