Although I do need line breaks within my title for my document's title page (I'm using the book class), I'd like to avoid hardcoding line breaks in the argument passed to the \title command, for three reasons:

  1. I always endeavour to separate form and content, for maintainability reasons.
  2. The title may need to be inserted elsewhere in the document, in places where line breaks within it are not warranted.
  3. I pass my title to\hypersetup{pdftitle=...}; hyperref returns a warning,

Token not allowed in a PDF string (PDFDocEnconding):(hyper ref) removing `\\'

if the title contains some \\, and I want to limit the number of compilation warnings to the bare minimum.

How can I effect line breaks at specific places within the title, upon inserting the latter somewhere in my document, without hardcoding \\'s in the \title{...} command? What's the best practice?


\author{Me, me, me}
%\title{Me, myself, and I}      % compiles without mishap; strictly content
\title{Me,\\ myself, \\ and I}  % compilation warnings occur; form and content are mixed

    pdftitle = \@title,

  • @AndrewSwann I didn't think the question warranted an MWE, but sure; it's on the way. – jub0bs Aug 9 '13 at 12:19
  • @Jubobs, I think Andrew Swann may have had the same though as me, I'd like to figure out why you need a forced line break in the title, rather than a subtitle – Chris H Aug 9 '13 at 12:21
  • 2
    Well for one thing, the title macro depends on the documentclass, and may or may not take an optional argument that could be used. Then there is \textorpdfstring for hyperref... – Andrew Swann Aug 9 '13 at 12:23
  • @ChrisH I can sympathisze with the general thought. Title layout on the page and its line breaks is quite critical with regard to emphasing/deemphasing certain words etc. – Andrew Swann Aug 9 '13 at 12:25
  • @AndrewSwann You're right: using \texorpdfstring would obviate the warning. However, what about my 2nd point? What if I need to format my title in a different way, somewhere else than on the title page? – jub0bs Aug 9 '13 at 12:30

if you always want certain phrases "tied together", use the ~ (tilde = tie) instead of a space between them. sometimes this works to encourage a line break, but sometimes you end up with an overfull box and still have to break the line explicitly.

(this is the same approach recommended in the texbook for keeping things like "Dr.~No" and "Figure~1" from breaking apart at the end of a line.)

the actual result depends on how the \title argument is processed; the stretch has to be defined with sufficient flexibility, which depends on the document class.

| improve this answer | |
  • This tilde trick let me line-break a section title properly, in a place where \\ would accidentally introduce a page break at the line break! – Camille Goudeseune Oct 21 '15 at 21:46

The easiest way is using option pdfusetitle and without spaces around \\ in \title:



\author{Me, me, me}
\title{Me,\\myself,\\and I}


Result of pdfinfo:

Title:          Me, myself, and I
Author:         Me, me, me

Otherwise, there is \texorpdfstring:

\title{My,\texorpdfstring{\\}{ }myself,\texorpdfstring{\\}{ }and I}

Or \pdfstringdefDisableCommands can be used, e.g.:

\pdfstringdefDisableCommands{\def\\#1{ #1}}

That is the definition that is used for the title with option pdfusetitle, it supports the following forms:

\title{Me,\\myself,\\and I}
\title{Me,\\ myself,\\ and I}

If you prefer more spaces:

\title{Me, \\ myself, \\ and I}

The trick with the argument is, that TeX does not accept a space as undelimited argument. Thus the space after \\ is gobbled.

The spaces are one of the reasons, that \\ is not provided by hyperref and a warning is given. The usual tricks (\unskip, \ignorespaces, ...) are not working inside the generation of PDF strings.

| improve this answer | |
  • Such a great answer! Thanks. I guess I can also use \texorpdfstring to include nonbreaking spaces in the title as recommended by Barbara. – jub0bs Aug 9 '13 at 13:33
  • 1
    @Jubobs: ~ is supported by hyperref, no need for \texorpdfstring. – Heiko Oberdiek Aug 9 '13 at 13:34
  • @HeikoOberdiek As a substitute for \ignorespaces inside the generation of PDF strings, you could use \romannumeral-^^ \q. Of couse, that leaves a preceeding space: this could be a problem. Alternatively, one could implement \unskip by adding a step after the full expansion and after stripping braces which would strip all occurrences of <space>\unskip. – Bruno Le Floch Aug 9 '13 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.