Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I was writing a document in LaTeX and found out that I am not able to properly align the text when I use \\ or \newline

Here is the code.

 \par{ {\bfseries{\today}} \vspace{1\baselineskip}

 Name \\
 Address \\
 Contact Details
       }

The output is like

enter image description here

What I want is that Address and Contact Details appear just below Name.

share|improve this question
2  
Using \noindent at the start of a paragraph prevents paragraph indentation. You can also use the tabular envirement to align things. –  Marc van Dongen Oct 3 '12 at 7:38
    
tabular does work but I wanted to make things more simpler, silly me should have tried \noindent . Thanks for the tip, worked fine :) –  Shashwat Oct 3 '12 at 7:57
add comment

1 Answer

up vote 5 down vote accepted

You can just add a \par at the end of each line which produces the first section below. Note that each paragraph is indented. As Marc van Dongen commented, if you want things to be at the left margin, you need to add a \noindent, as shown in the second example:

enter image description here

However, for this kind of material is better to use a tabular environment:

enter image description here

Notes:

  • The showframe package was used to show the margins of the page.
  • \bfseries does not take a parameter, so the correct usage would have been {\bfseries\today}.
  • You can use \bigskip, \medskip, \smallskip for vertical space adjustments, or add an optional space after in the tabular as \\[2.0ex]

Code:

\documentclass{article}
\usepackage{showframe}

\begin{document}
\textbf{\today} 
\vspace{1\baselineskip}

Name\par
Address\par
Contact Details

\bigskip
\noindent\textbf{\today} 
\vspace{1\baselineskip}
\par\noindent Name
\par\noindent Address
\par\noindent Contact Details

\bigskip
\noindent
\begin{tabular}{@{}ll}
\textbf{\today} \\[2.0ex]
Name            & Shashwat \\
Address         & 123 Any Street \\
Contact Details & myemail@provider.com \\
\end{tabular}
\end{document}
share|improve this answer
    
Thanks for the help and tips for skipping lines :) Will come handy . However I don't understand the function of @ in Latex can you please clarify the use of @{} inside tabular arguments –  Shashwat Oct 3 '12 at 14:02
1  
@Shashwat: In a table like environment such as tabular there is a space that is inserted in between columns. The @{} in this MWE is used to suppress the inter column spacing. So I put it before the first column so that there is no space to the left of the first column -- hence it aligns with the margin. Try taking it out to see the effect. –  Peter Grill Oct 3 '12 at 19:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.