Text FormattingTwo columns, both left justified

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Bakster
Posts: 2
Joined: Sun Dec 05, 2010 2:27 am

Two columns, both left justified

Post by Bakster »

I want two addresses on the same lines, one on the left and one on the right. I achieved this with:

Code: Select all

\noindent \textbf{Home Address} \hfill \textbf{Term Address} \\
Address Line 1 \hfill Address Line 1 \\
Address Line 2 \hfill Address Line 2 \\
Address Line 3 \hfill  Address Line 3 \\
Postcode \hfill Postcode \\
However, the address on the right of the page is right justified, and I want it to be left justified (within its own 'block' on the right hand side of the page). Is there a simple modification I can make to achieve this, or do I require a more substantial solution such as creating a table?

I tried creating a table but couldn't get it to work, one reason being that the table is indented and I don't know how to align it to the left margin (there were a few other problems too).

Any help is much appreciated!
Last edited by Bakster on Wed Mar 16, 2011 2:39 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Two columns, both left justified

Post by gmedina »

Hi,

as you suspected, a table is the solution:

Code: Select all

\documentclass{article}

\newlength\mylena
\newlength\mylenb
\setlength\mylena{\linewidth}
\settowidth\mylenb{\textbf{Term Address}}
\addtolength\mylena{-2\mylenb}

\begin{document}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\noindent\begin{tabular*}{\linewidth}{@{}l@{\hspace{.5\mylena}}l}
  \textbf{Home Address} & \textbf{Term Address} \\ 
  Address Line 1 & Address Line 1 \\
  Address Line 2 & Address Line 2 \\
  Address Line 3 &  Address Line 3 \\
  Postcode & Postcode
\end{tabular*}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Bakster
Posts: 2
Joined: Sun Dec 05, 2010 2:27 am

Re: Two columns, both left justified

Post by Bakster »

That's great, thank you!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Two columns, both left justified

Post by localghost »

Bakster wrote:That's great […]
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).


Best regards and welcome to the board
Thorsten
Post Reply