开发者

Converting newlines to spaces in Latex

开发者 https://www.devze.com 2023-01-19 15:40 出处:网络
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 ou

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 inform开发者_开发百科ative line

ToC:

First Line: Second more informative line


you can define alternative chapter titles for the toc:

\chapter[toc title]{regular title}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消