0

I have seen some similar posts, but none of the suggested solutions worked in my case, so I need to post the question.

The problem seems simple, but somehow I mess it up. I have a minipage on my front cover and within this minipage I have two titles of parts of my thesis, followed by the advisor. The advisor should be aligned right and if the title does not exceed one line, then the advisor should be put in the next line (and flushed right). For long titles this works, but not for short ones.

I have first tried \\ \hfill, and although this did not produce vertical space (as expected), it also did not flush the advisor to the right. I then tried flushright (see MWE), but this produces the vertical space seen in the output.

How do I flush the advisor to the right if the line is empty, without producing additional vertical white space?

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}

Current output:

Current output

Desired output:

Desired output

Any help is very appreciated!

1

Too long for a comment, here is some code from the memoir class

\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}

enter image description here

  • @JohnA. note that memoir is more or less a drop in replacement for the book class, plus more... If it worked mark the answer as approved. – daleif Feb 1 '18 at 13:52

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.