0

I have this heading

\def\@oddhead{\vbox{\vss\centerline{\color{gray}\small { \bf \texttt{Article 
published in \textit{\thejournalname}. doi: 10.1029/2019False1234  \newline \textcopyright 2020 American Foo Bar. All Rights Reserved} } }\vskip24pt } }
\let\@evenhead\@oddhead
}

The problem is that the \newline is not working, and thus the heading appears in a single line.

Is there any way to force a new line in a \vbox?

4
  • What exactly are you trying to do? And why are you using a \vbox and not something like \parbox (which does support `\newline)
    – daleif
    Commented Jun 11, 2020 at 12:29
  • @daleif If I use \parbox the header does not show up
    – D1X
    Commented Jun 11, 2020 at 12:37
  • 1
    Then show a complete (but minimal) example. I use parbox in headers all the time without issues.
    – daleif
    Commented Jun 11, 2020 at 12:42
  • \def, \vbox, \vss, \let are tex primitives \centerline is a plain tex macro in latex but not fitting the latex box system so shouldn't be used, \bf is not defined by default in latex. Given that so little of the code you post is actually latex it's not surprising that \newline does not work (but \centerline is like \mbox and is always one line) Commented Jun 11, 2020 at 15:10

1 Answer 1

1

You are trying to make a line break in \centerline, which is not allowed.

You might do

\makeatletter
\def\@oddhead{%
  \vbox to \headheight{
    \vss
    \color{gray}\small\bfseries\ttfamily
    \centerline{Article published in \textit{\thejournalname}. doi: 10.1029/2019False1234}
    \centerline{\textcopyright 2020 American Foo Bar. All Rights Reserved}
  }%
}
\let\@evenhead\@oddhead
\makeatother

but using a \parbox is easier.

\documentclass{article}
\usepackage{xcolor,lipsum}

\pagestyle{headings}

\makeatletter
\def\@oddhead{%
  \parbox[b][\headheight]{\textwidth}{
    \centering\color{gray}\small\bfseries\ttfamily
    Article published in \textit{\thejournalname}. doi: 10.1029/2019False1234\\
    \textcopyright 2020 American Foo Bar. All Rights Reserved
  }%
}
\let\@evenhead\@oddhead
\makeatother

\providecommand{\thejournalname}{Foo Journal}

\begin{document}

\lipsum[1-20]

\end{document}

enter image description here

Note. The standard fonts don't have boldface typewriter type. Since the font used by the OP is unknown, I left the \bfseries declaration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .