Hi all,
I want to create simple multi-line equation for arithmetic worksheets, but it seemed to be quite tough to create.
I just want to create the following:
1234
+ 6
------
and I need to right-justify the numbers, while filling the space between the operator and the number. The \hfill command doesn't work in align* env, and using multiple '&' symbols to align the numbers doesn't seem to work.
eg.
\begin{align*}
& 1234&\\
+& 6&
\end{align*}
produces something like
1234
+6
I also tried using flalign env, since some comment in this forum suggests that I may be able to achieve what I want with extra tabs. I have not been able to successfully align the numbers with flalign, and it gives me line numbering, which I don't really want.
Can anyone suggest what I need to do to create this?
Thanks..
Math & Science ⇒ Command like '\hfill' inside 'align' environment
Command like '\hfill' inside 'align' environment
Last edited by ezrahn on Wed Jun 22, 2011 10:26 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Command like '\hfill' inside 'align' environment
The amsmath package provides several more environments for alignment.
See the package manual for details. More about math typesetting in the excellent »Math mode« document.
Best regards and welcome to the board
Thorsten
Code: Select all
\documentclass{article}
\usepackage{mathtools} % loads »amsmath«
\begin{document}
\begin{alignat*}{2}
&& 1234 \\
+ && 6
\end{alignat*}
\end{document}
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Command like '\hfill' inside 'align' environment
Works as expected. Thanks for your help.
Re: Command like '\hfill' inside 'align' environment
Now if there is anyway I can underline them, it would have been great 
\begin{alignat*}{2}
&& 1234\\
\underline{ +&& 6 }
\end{alignat*}
seems to be invalid, and
\begin{alignat*}{2}
&& 1234\\
\underline{+}&&\underline{ 6 }
\end{alignat*}
renders fine, but the two underlines do not make 1 continuous line..
I'd imagine that there must be a way to write this introductory arithmetic forms..

\begin{alignat*}{2}
&& 1234\\
\underline{ +&& 6 }
\end{alignat*}
seems to be invalid, and
\begin{alignat*}{2}
&& 1234\\
\underline{+}&&\underline{ 6 }
\end{alignat*}
renders fine, but the two underlines do not make 1 continuous line..
I'd imagine that there must be a way to write this introductory arithmetic forms..
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Command like '\hfill' inside 'align' environment
You can consider the align environment as some kind of array. So it is possible to use the \cline command for underlining.
By the way, the forum software offers a »Code« environment to tag code as such. You can find it in the button list right above the input window while composing a post. Perhaps you noticed that I did so. Would be very kind if you use it, too. It just keeps a post clear and legible.
Code: Select all
\documentclass{article}
\usepackage{mathtools} % loads »amsmath«
\begin{document}
\begin{alignat*}{2}
&& 1234 \\
+ && 6 \\[-4\jot] \cline{1-3}
\end{alignat*}
\end{document}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Command like '\hfill' inside 'align' environment
Thanks, LocalGhost! Appreciate your help..