将标题向下推而不是向上推至第二行

将标题向下推而不是向上推至第二行

考虑这个带有长标题的文档:

\documentclass[twoside=semi]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum}
\rohead{This is a really long header, it's so long it even needs a second line. No really, it does need a second line!}
\lehead{This is a short line for comparison.}
\begin{document}
\lipsum[1-24]
\end{document}

偶数页上的较短页眉与奇数页上的长页眉形成了对比。

预期的行为是奇数页页眉的第一行与偶数页页眉的高度相同。因此,应该降低文本区域的高度,但实际上,文本区域仍保留在原处,而页眉向上移动到页面的顶部边缘。

我怎样才能获得期望的行为?

答案1

您可以使用\parbox,但必须注意标题不要与文本区域重叠:

\documentclass[twoside=semi]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum}

\rohead{%
  \parbox[t][\baselineskip]{\linewidth}{\raggedleft%
    This is a really long header, it's so long it even needs a second line.
    No really, it does need a second line!%
  }%
}

\lehead{This is a short line for comparison.}
\begin{document}
\lipsum[1-24]
\end{document}

在此处输入图片描述

答案2

如果您愿意提供手动换行符,那么此堆栈可能会起作用:

\documentclass[twoside=semi]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum,stackengine}
\setstackEOL{\\}
\rohead{\smash{\Longunderstack[r]{This is a really long header, it's so long 
  it even needs a second line. No really, it does\\need a second line!}}}
\lehead{This is a short line for comparison.}
\begin{document}
\lipsum[1-24]
\end{document}

在此处输入图片描述

相关内容