# Left and right aligned on same line

I am currently busy typesetting my thesis in LaTeX, but I am stuck on something with my cover/title page. At the bottom of the page, I need to type my name and my supervisor's name.

This is a rough idea (written in Word) of the layout in which I wish to typeset my name and my supervisor's name.

However, I have no idea how I can get the left and right alignments for my name on the left and my supervisor's name on the right.

Can anybody please show me how I can go about typsetting something like this in LaTeX?

There are a couple things you could try. A simple technique is to use \hfill, such as

\documentclass{article}
\begin{document}

\textbf{\underline{Student:}}
\hfill
\textbf{\underline{Supervisor:}} \\
Mr. Thatshisname
\hfill
Prof. Whatshisname

\end{document}


This will produce the following:

This does not quite reproduce the spacing for the "Supervisor" word as shown in your sample. Another approach will reproduce this better, although it's a little more involved. This uses \hfill along with the minipage environment:

\documentclass{article}
\begin{document}

\begin{minipage}{2in}
\textbf{\underline{Student:}} \\
Mr. Thatshisname
\end{minipage}
\hfill
\begin{minipage}{1.3in}
\textbf{\underline{Supervisor:}} \\
Prof. Whatshisname
\end{minipage}

\end{document}


The size of the first minipage does not matter too much, since \hfill will fill the space, but the size of the second minipage needs to be tweaked to get the right edge as close to the margin as possible without forcing a line break. I used the showframe package to make that process easier, but perhaps someone else has a more elegant solution. Here is the output:

In order to get this on the bottom of the page, you can try using the \vfill command. Another approach to achieving the result you're looking for is by using the fancyhdr package (read "fancy header"):

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\lfoot{\textbf{\underline{Student:}} \\
Mr. Thatshisname}
\rfoot{\textbf{\underline{Supervisor:}}
\phantom{MMMi}\\
Prof. Whatshisname}

\begin{document}
\lipsum[1-4]
\end{document}


This will place these words on the bottom of every page with the pagestyle fancy. If you want it only on the first page, then use \thispagestyle{fancy} after \begin{document} instead of \pagestyle{fancy} as shown in my example. I had to redefine the \headrulewidth to zero so that the line did not show up at the top of the page (can someone comment on this answer if there is a "nicer" way to do this?). This solution also has the same problem as the first, where "Supervisor" is pushed all the way to the margin. However, I used the \phantom command to add some white space, and fiddled with the input to make it look right. Here is that output:

Hope this helps!

\begin{titlepage}
... whatever should be here ...
for a titlepage

\vfill\noindent
\begin{tabular}[t]{@{}l}
\underline{\textbf{Student:}}\\  Mr. Thatshisname
\end{tabular}
\hfill% move it to the right
\begin{tabular}[t]{l@{}}
\underline{\textbf{Supervisor:}}\\ Prof. Whatshisname
\end{tabular}
\end{titlepage}


• Is it good practice to use tabulars in LaTeX for alignment? I'm asking since in HTML for example this frowned upon. Well they have there <div>'s forf this purpose, but I'm still wondering. Tables and alignet text are to different things IMO.. – manthano Feb 23 '16 at 8:05
• tabulars (arrays) can be aligned at top [t], center (default) [c] or the baseline [b]. For the current line the tabular itself is nothing else than a box. – user2478 Feb 23 '16 at 8:14
• True, but does this not soften the barrier between "meaning" and "purpose"? The tabular environment is supposed to set tables; if i start aligning my text with it my code becomes harder to read and I can never redefine the tabular environment if I want to alter the look of my tables – manthano Feb 23 '16 at 8:30
• Feel free, to use it in your way. But I wrote more than 10,000 pages with TeX and I never had the feeling that my way of using tabulars for aligning text makes the code hard to read. – user2478 Feb 23 '16 at 8:36

This uses a tabularx table to use the whole \linewidth and fills the rest of the table with an (empty!) X column.

\documentclass{book}
\usepackage{tabularx}
\usepackage{showframe}

\newcommand{\namestyle}[1]{#1}

\begin{document}
\noindent\begin{tabularx}{\linewidth}{@{}p{4cm}Xp{4cm}@{}}
\namestyle{Mr. Gumby}    & & \namestyle{Prof. Gumby} \tabularnewline
\end{tabularx}

\end{document}


I remove the underlining on purpose -- the showframe package can be omitted of course.

As tables or minipages are not an option to answer anymore, something a little more quirky:

\documentclass{article}
\usepackage[papersize={12cm,10cm}]{geometry}
\usepackage{lipsum}
\usepackage{calc}
\def\signat#1#2{%
\makebox[\widthof{#2}][l]{\vbox{%
\textbf{\underline{#1:}}\\[5pt] #2}}}
\begin{document}
\lipsum[2]\vfill
{\parindent0pt
\signat{Student}{Mr. Thatshisname}\hfill
\signat{Supervisor}{Prof. Whatshisname}}
\end{document}


Well, less quirky:

\def\signat#1#2{\parbox{\widthof{#2}}{\textbf{\underline{#1:}}\par #2}}


Note: Take care that the "p" of "Supervisor" make the underline lower than in "Student". A good reason to not underline, or at least underline \smash{#1:}, or \strut #1, or use the soul package.

Are you sure that you want the supervisor name flush right? Here it is much more common to have something like this:

\documentclass{article}
\usepackage{showframe} % just to show the page boundaries
\begin{document}

whatever...

\vfill
\noindent \parbox[t]{0.5\linewidth}{%
\underline{\textbf{Student}} \\ Mr. Studentname \\ \vspace{2cm} } %
\parbox[t]{0.45\linewidth}{%
\underline{\textbf{Supervisor}} \\ Mr. Supervisorname}

\end{document}


...with the place for signing under the names and flush left with the names.