### LaTeX users online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 7 guests

### LaTeX Friends

Sponsored by DANTE e.V.: The German speaking TeX Users Group

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

### LaTeX Forum: General

Add tags LaTeX specific issues not fitting into one of the other forums of this category.
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:

Code: Select all  •  Open in online LaTeX editor
\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 139044 times

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

Posts: 3
Joined: Sat Oct 25th, 2008

Hi Alex,

welcome to the board!
Just insert \hfill, for example:
Code: Select all  •  Open in online LaTeX editor
Left aligned text\hfill right aligned text

Stefan

Stefan_K

Posts: 7456
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Thanks for the reply. When I insert \hfill between the two texts, like so:

Code: Select all  •  Open in online LaTeX editor
\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.
anonymous188

Posts: 3
Joined: Sat Oct 25th, 2008

Hi Alex,

that's caused by the paragraph indentation, insert \noindent before the first minipage:
Code: Select all  •  Open in online LaTeX editor
\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

Stefan_K

Posts: 7456
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Code: Select all  •  Open in online LaTeX editor
\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.

Juanjo

Posts: 656
Joined: Sat Jan 27th, 2007

Perfect! Thanks for your help guys.

-Alex W.
anonymous188

Posts: 3
Joined: Sat Oct 25th, 2008