在小页面内对齐文本

在小页面内对齐文本

我见过一些类似的帖子,但是所有建议的解决方案都不适用于我的情况,所以我需要发布这个问题。

问题看似简单,但不知何故我搞砸了。我的封面上有一个小页面,在这个小页面中,我有两个论文部分的标题,后面是导师。导师应该右对齐,如果标题不超过一行,那么导师应该放在下一行(并向右对齐)。对于长标题,这种方法可行,但对于短标题则不行。

我首先尝试了\\ \hfill,虽然这没有产生垂直空间(如预期的那样),但它也没有将顾问向右对齐。然后我尝试了 flushright(参见 MWE),但这会产生输出中看到的垂直空间。

如果该行为空,如何将顾问刷新到右侧,而不产生额外的垂直空白?

梅威瑟:

\documentclass{book}
\begin{document}
\begin{minipage}[t]{1\textwidth}
{Part \textrm{I}: This is a very very very  very very very very very very very very long title name \hfill Advisor: First Name \textsc{Second Name}}\vspace{0.5\baselineskip}
{Part \textrm{II}: This is a very very very long title name}\\%
{\begingroup\setlength\topsep{0pt}
    \begin{flushright}
        Advisor: First Name \textsc{Second Name}
    \end{flushright}
\endgroup}
\end{minipage}
\end{document}

电流输出:

电流输出

期望输出:

期望输出

非常感谢您的帮助!

答案1

评论太长了,下面是一些来自memoir类的代码

\documentclass{book}

\makeatletter
% verbatim copy from the memoir class
\newcommand*{\sourceatright}[2][2em]{{%
    \unskip\nobreak\hfil\penalty50
    \hskip#1\hbox{}\nobreak\hfil{#2}
    \parfillskip\z@\finalhyphendemerits=0\par}}
\makeatother

\begin{document}



\begin{minipage}[t]{1\textwidth}
Part \textrm{I}: This is a very very very  very very very very very
very very very long title name
\sourceatright{Advisor: First Name \textsc{Second Name}}

\vspace{0.5\baselineskip}

Part \textrm{II}: This is a very very very long title name
\sourceatright{Advisor: First Name \textsc{Second Name}}
\end{minipage}
\end{document}

在此处输入图片描述

相关内容