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.

The \rules not aligned. I want to be in parallel to be each other and start from the same position horizontally.

Here is the code:

\documentclass[12pt]{book}
\begin{document}
\begin{titlepage}
\rule{\linewidth}{4pt}
\rule{\linewidth}{4pt}
\end{titlepage}
\end{document} 

enter image description here

share|improve this question
    
You could use \parindent=0pt... –  Malipivo May 12 at 17:00
    
In addition to what others have said, your two rules are on the same line separated by a word space. They only come one below the other as they are longer than half the line width, ans so Tex has broken the paragraph into two lines. so it's probably more natural to put a blank line between them then they would have both been indented (or not) by the same amount. –  David Carlisle May 12 at 17:22

3 Answers 3

up vote 7 down vote accepted

You need to add a \noindent:

enter image description here

Code:

\documentclass[12pt]{book}
\begin{document}
\begin{titlepage}
\noindent
\rule{\linewidth}{4pt}
\rule{\linewidth}{4pt}
\end{titlepage}
\end{document} 
share|improve this answer

You're setting two blocks (\rules in this case) that form part of a single paragraph where the first line of a paragraph typically has an indentation (of length \parindent). You'll see exactly the same if you set a regular paragraph below the \rules.

enter image description here

\documentclass{book}
\begin{document}

\rule{\linewidth}{4pt}
\rule{\linewidth}{4pt}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Praesent vel eleifend eros, congue egestas nibh. Donec quis 
vulputate felis, id aliquet dolor. Praesent posuere pretium massa et scelerisque. 

\noindent\rule{\linewidth}{4pt}
\rule{\linewidth}{4pt}

\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Praesent vel eleifend eros, congue egestas nibh. Donec quis 
vulputate felis, id aliquet dolor. Praesent posuere pretium massa et scelerisque. 

\end{document}

\noindent removes the indentation of the paragraph causing them to be set flush with the left margin.

A global change can be initiated using \setlength{\parindent}{0pt}, or as in your titlepage case, the scope can be limited to

\begin{titlepage}
  \setlength{\parindent}{0pt}%
  ...
\end{titlepage}
share|improve this answer

With the etoolbox package, you don't even have to think of adding whatever:

\documentclass{book}

\usepackage{etoolbox}
\pretocmd\rule{\noindent}{}{}

\begin{document}

\rule{\linewidth}{2pt}
\rule{\linewidth}{2pt}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Praesent vel eleifend eros, congue egestas nibh. Donec quis
vulputate felis, id aliquet dolor. Praesent posuere pretium massa et scelerisque.

\end{document} 

enter image description here

share|improve this answer

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.