Math & Science ⇒ Command like '\hfill' inside 'align' environment
Command like '\hfill' inside 'align' environment
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..
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Command like '\hfill' inside 'align' environment
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
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Command like '\hfill' inside 'align' environment
Re: Command like '\hfill' inside 'align' environment

\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
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}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10