I used the code below to format some information but the last line before the red line is not right aligned. I can`t find the problem in the code. Any suggestion? Thanks.
\documentclass[11pt,a4paper]{article}
\usepackage{color}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0em}
\begin{document}
\begin{samepage}
{\color{blue}\hrule height 2pt}
\vspace{.1\baselineskip}
{\Large Some important text}
\hfill
{\large \textit{And more}} \\
{\small More some text}
\hfill \textit{Important person:}~Me \\[.3\baselineskip]
{Year:~2018, Volume:~1, Nr.:~1}
\hfill
Date 1: YYYY-MM-DD\\
{Classification:~A}
\hspace{\fill}
Date 2: YYYY-MM-DD
\vspace{.3\baselineskip}
{\color{red}\hrule height 2pt}
\end{samepage}
\end{document}
Best Answer
You have to protect end of lines in a few places, otherwise a space might appear there.
Edit: A comment at the end of the line? Seriously?
This is something that everyone already had problems with (the "everyone" link is the best
:P
).What happens here is that (in normal situations) TeX interprets a line break as a space character, so when you type:
the result is the same as if you had typed:
(notice the space after
c
). But when you type:TeX ignores everything that comes after the
%
, and this includes the line break, so it is essentially the same as:And that's why you had a space after the
DD
in your code.When you have the time, I suggest you read koleygr's answer here and if you want a more lengthy explanation, my answer here.