1

I want my text in title (executor and supervisor fields) to be flushed right and aligned left. Also I need to have line breaks in it. For now, I've made it using flushright, tabular and parbox

\documentclass{article}
\begin{document}    
\begin{flushright}
\begin{tabular}{ll}
    executor:     & \textit{\parbox[l]{6cm}{\vspace*{1em} Name  \\ some text} }\vspace{0.5em} \\
    supervisor :  & \textit{Name}       \\
\end{tabular}
\end{flushright}
\end{document}

so it looks like this now: so it looks like this now

But maybe there is more elegant solution.

1
  • Welcome to TeX.SE!
    – Mensch
    Nov 18, 2021 at 21:47

3 Answers 3

1

You can use a \parbox or better as Dan showed a p column, however this requires you to fix a width of the box so if the text is shorter, the resulting block will not look flush right. In some contexts that is OK, but if you want the block flush to the right margin with its longest line, then it is easier not to use a parbox, as in the second example here.

enter image description here

\documentclass{article}
\begin{document}

\noindent X\dotfill filler text\dotfill X

\begin{flushright}
\begin{tabular}{lp{6cm}}
executor:    & \textit{Name\newline Some text}\\
supervisor : & \textit{Name}\\
\end{tabular}
\end{flushright}

\noindent X\dotfill filler text\dotfill X

\begin{flushright}
\begin{tabular}{ll@{}}
executor:    & \textit{Name}\\
             & \textit{Some text}\\
supervisor : & \textit{Name}\\
\end{tabular}
\end{flushright}

\noindent X\dotfill filler text\dotfill X
\end{document}
2

You can use the p column option and \newline rather than the parbox and the \vspaces which I think is slightly cleaner

\documentclass{article}
\begin{document}
\begin{flushright}
\begin{tabular}{lp{6cm}}
executor:    & \textit{Name\newline Some text}\\
supervisor : & \textit{Name}\\
\end{tabular}
\end{flushright}
\end{document}

enter image description here

1
  • In addition, if you wish a bigger vertical space, use \\[2em] for example, to change the vertical space between lines.
    – Sigur
    Nov 18, 2021 at 22:46
1

For this job it's simpler if you add a row with a &, but you can also get away with a different syntax:

\documentclass{article}
\usepackage{array,booktabs}



\begin{document}    

\begin{flushright}
\newcommand{\splitcell}[1]{\begin{tabular}[t]{@{}l@{}}#1\end{tabular}}

\begin{tabular}{@{} l @{\hspace{1em}} >{\itshape}l @{}}
  executor:     & \splitcell{Name \\ some text} \\
  \addlinespace
  supervisor :  & Name
\end{tabular}
\end{flushright}

\end{document}

Note the @{} commands to remove leading and trailing padding around the tabular.

I used \addlinespace for separating more clearly the two entries.

For the picture I added the frame to show that the table is indeed flush right.

enter image description here

2
  • So you've created a subtabular in the cell of the original one, am I right?
    – lazba
    Nov 18, 2021 at 23:33
  • @lazba Yes, that's the idea
    – egreg
    Nov 19, 2021 at 7:50

You must log in to answer this question.

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