Featured Book

LaTeX Beginners Guide

Who is online

In total there are 32 users online :: 1 registered, 0 hidden and 31 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: Google [Bot] and 31 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

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

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

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

Postby anonymous188 on Sat Oct 25th, 2008

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 writeLaTeX
\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.

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

example copy.jpg
My output.
example copy.jpg (15.09 KiB) Viewed 119167 times
anonymous188
 
Posts: 3
Joined: Sat Oct 25th, 2008

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

Postby Stefan_K on Sat Oct 25th, 2008

Hi Alex,

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

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6379
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

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

Postby anonymous188 on Sat Oct 25th, 2008

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

Code: Select all  •  Open in writeLaTeX
\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

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

Postby Stefan_K on Sat Oct 25th, 2008

Hi Alex,

that's caused by the paragraph indentation, insert \noindent before the first minipage:
Code: Select all  •  Open in writeLaTeX
\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
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6379
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

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

Postby Juanjo on Sat Oct 25th, 2008

What about this?
Code: Select all  •  Open in writeLaTeX
\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.
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007

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

Postby anonymous188 on Sat Oct 25th, 2008

Perfect! Thanks for your help guys.

-Alex W.
anonymous188
 
Posts: 3
Joined: Sat Oct 25th, 2008


Return to General

Who is online

Users browsing this forum: Google [Bot] and 31 guests