0

I would like to move a series of consecutive lines (AAA-FFF) to the right of the page, but I only move the first one (AAA). This is the LaTex source code:

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[a4paper,top=2.5cm,bottom=2cm,left=2cm,right=2cm]{geometry}
\setlength{\parindent}{0pt}
\pagestyle{empty}
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\begin{document}
\hfill AAA \newline
\hfill BBB \newline
\hfill CCC \newline
\hfill DDD \newline
\hfill EEE \newline
\hfill FFF \\

\today \

XXX \newline YYY \newline ZZZ \

My text starts here... \end{document}

Can someone help me? Thanks in advance.

Bernard
  • 271,350
LJG
  • 103
  • 1
    Welcome to texexchange. It hasn't been that long since I signed up myself and I've already learned a lot. For your problem, I don't really know how to explain it , but it works.

    With \null before the \hfill

    – pascal974 May 07 '22 at 14:30

2 Answers2

3

I describe the reason why only AAA is at the right margin. The \newline does (roughly speaking) \nobreak\hfil\break. You are using \hfill primitive at the left side. A text follows and then there is \nobreak\hfil\break. First line: \hfill is more stretchable than \hfil used in the \newline macro, so AAA is at the right margin. But the \break macro expands to \penalty-10000 and it makes forced break of the line. Following "discardable items" are ignored by TeX. Your \hfill is a glue, so it is a discarable item. It is ignored. Next line includes only BBB\nobreak\hfil\break so the BBB is on the left side.

wipet
  • 74,238
2

If all you want to is align text to the right side of the page I would suggest the usage of \raggedleft as follows.

{\raggedleft
AAA \\
BBB \\
CCC \\
DDD \\
EEE \\
FFF \\
}

Please note that I changed \newline to \\ since the usage of \newline would lead to undesired results.
You can read more on that topic here.

Bernard
  • 271,350