LaTeX forum ⇒ Text FormattingTwo columns, both left justified

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

Two columns, both left justified

Postby Bakster » Wed Mar 16, 2011 3:24 am

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

  1. \noindent \textbf{Home Address} \hfill \textbf{Term Address} \\
  2. Address Line 1 \hfill Address Line 1 \\
  3. Address Line 2 \hfill Address Line 2 \\
  4. Address Line 3 \hfill Address Line 3 \\
  5. 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.

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

Postby gmedina » Wed Mar 16, 2011 4:24 am

Hi,

as you suspected, a table is the solution:

  1. \documentclass{article}
  2.  
  3. \newlength\mylena
  4. \newlength\mylenb
  5. \setlength\mylena{\linewidth}
  6. \settowidth\mylenb{\textbf{Term Address}}
  7. \addtolength\mylena{-2\mylenb}
  8.  
  9. \begin{document}
  10.  
  11. 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
  12.  
  13. \noindent\begin{tabular*}{\linewidth}{@{}l@{\hspace{.5\mylena}}l}
  14. \textbf{Home Address} & \textbf{Term Address} \\
  15. Address Line 1 & Address Line 1 \\
  16. Address Line 2 & Address Line 2 \\
  17. Address Line 3 & Address Line 3 \\
  18. Postcode & Postcode
  19. \end{tabular*}
  20.  
  21. \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

Postby Bakster » Wed Mar 16, 2011 4:34 am

That's great, thank you!

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed Mar 16, 2011 11:33 am

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
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests