## LaTeX forum ⇒ General ⇒ question: how to align left and align right in same line

LaTeX specific issues not fitting into one of the other forums of this category.
anonymous188
Posts: 3
Joined: Sat Oct 25, 2008 12:28 am

### question: how to align left and align right in same line

Hey everyone,

I have to prepare a report using a specific format, of which I attached an image (1). The only problem is I don't know how to:

1. Align two items on the same line, one left one right
2. Make them both appear the same as a \section{} or \subsection{} header.

The best attempt I've had was the following code:

\begin{minipage}{0.5\textwidth}\begin{flushleft}     \subsection*{Alex W}\end{flushleft}\end{minipage}\begin{minipage}{0.5\textwidth}\begin{flushright}     \textbf{\large October 24, 2008}\\[1.5cm]\end{flushright}\end{minipage}\\\subsection*{Bahaa B}

which has its output shown in the second picture. As you can see, my name isn't quite justified all the way to the left. Any help would be appreciated.

Thanks,

Alex W.

Note that Name and Date are aligned left and right, respectively, on the same line.
lab_report_format_copy.jpg (54.56 KiB) Viewed 146105 times

My output.
example copy.jpg (15.09 KiB) Viewed 146109 times

Stefan Kottwitz
Posts: 7875
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Hi Alex,

welcome to the board!
Just insert \hfill, for example:
Left aligned text\hfill right aligned text

Stefan

anonymous188
Posts: 3
Joined: Sat Oct 25, 2008 12:28 am
Thanks for the reply. When I insert \hfill between the two texts, like so:

\begin{minipage}{0.5\textwidth}\begin{flushleft}     \subsection*{Alex W}\end{flushleft}\end{minipage}\hfill\begin{minipage}{0.5\textwidth}\begin{flushright}     \textbf{\large October 24, 2008}\\[1.5cm]\end{flushright}\end{minipage}\\\subsection*{Bahaa B}

I get the same result as last time. I experimented by putting the command in various places wrt the two, but I don't think it's solving the problem. Correct me if I'm wrong, but I'm assuming \hfill lets the date go all the way to the end (horizontally). If that's the case, then I don't know if it would help align my name all the way to the left.

Thanks again for any help clarifying this.

Regards,

Alex W.

Stefan Kottwitz
Posts: 7875
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Hi Alex,

that's caused by the paragraph indentation, insert \noindent before the first minipage:
\noindent\begin{minipage}{0.5\textwidth}...

Note that those two minipages will extend \textwidth, because there will be a small space between the two minipages, I would make them smaller.

Stefan

Juanjo
Posts: 656
Joined: Sat Jan 27, 2007 12:46 am
\noindent{\bfseries\large Alex W\hfill October 24, 2008} \subsection*{Bahaa B}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

anonymous188
Posts: 3
Joined: Sat Oct 25, 2008 12:28 am
Perfect! Thanks for your help guys.

-Alex W.