0

I use the alignat{2} environment with & and && between the items:

\usepackage{geometry,amsmath}
\geometry{left=1.5cm,right=7cm,top=2.5cm,bottom=1.5cm}

\begin{document}
\begin{alignat*}{2}
&\textbf{31.}\; x+y && \textbf{32.}\; x-y\\
&\textbf{33.}\; a+b && \textbf{34.}\; a-b \\
&\textbf{35.}\; u+v && \textbf{36.}\; u-v\\
\end{alignat*}
\end{document}

How do I set the spacing so as to change the horizontal locations of "31/33/35" and "32/34/36"? Thanks!

5
  • 5
    As always, you are more likely to get help if ypu provide code that shows your issue. The code should be a full minimal example others can copy and test as is
    – daleif
    Nov 1, 2023 at 6:12
  • @daleif I am trying to provide the code here. But I am using a template that many environments are pre-defined. When I put the code in a different tex file and run, everything just messed up. Nov 1, 2023 at 7:07
  • just make a simple complete document that just uses amsmath, you can use x=y for equations, you don't need your real formulae if you are asking about spacing Nov 1, 2023 at 7:10
  • That is why it is called minimal. Remove everything the is not nessary for the issue you have. Often this process leads you to figure out what is wrong in a given situation, so reating a proper MWE is an important skill.
    – daleif
    Nov 1, 2023 at 7:48
  • OK. Now the question is very simple. Hope it works. Nov 1, 2023 at 7:59

2 Answers 2

2

The reason align adds space is exactly this use case, so I would use align* and let amsmath add the space, but if using alignat you can add space (I used 2em, \qquad here but you can use \hspace{2cm} or whatever you want. I also show a version using alignment points wihin the expression.

enter image description here

\documentclass{article}
\usepackage{geometry,amsmath}
\geometry{left=1.5cm,right=7cm,top=2.5cm,bottom=1.5cm}

\begin{document}
original
\begin{alignat*}{2}
&\textbf{31.}\; x+y && \textbf{32.}\; x-y\\
&\textbf{33.}\; a+b && \textbf{34.}\; a-b \\
&\textbf{35.}\; u+v && \textbf{36.}\; u-v\\
\end{alignat*}

align
\begin{align*}
&\textbf{31.}\; x+y && \textbf{32.}\; x-y\\
&\textbf{33.}\; a+b && \textbf{34.}\; a-b \\
&\textbf{35.}\; u+v && \textbf{36.}\; u-v\\
\end{align*}

alignat, spaced

\begin{alignat*}{2}
&\textbf{31.}\; x+y &\qquad& \textbf{32.}\; x-y\\
&\textbf{33.}\; a+b && \textbf{34.}\; a-b \\
&\textbf{35.}\; u+v && \textbf{36.}\; u-v\\
\end{alignat*}

align, aligned
align
\begin{align*}
\textbf{31.}&\; x+y &\textbf{32.}&\; x-y\\
\textbf{33.}&\; a+b &\textbf{34.}&\; a-b \\
\textbf{35.}&\; u+v &\textbf{36.}&\; u-v\\
\end{align*}


\end{document}
2
  • Thanks. Is there a way to make the odd numbers aligned to the left, while the even numbers aligned to the middle of the row? Nov 1, 2023 at 13:35
  • that is the how they are all aligned except the last block where I moved the & so the numbers all align right towards the equation, although you can not see if all the numbers are 2 digit, see 8,9,10,11 to see the difference Nov 1, 2023 at 13:53
0

I'd use tasks for this job.

\documentclass{article}
\usepackage{geometry,amsmath}
\usepackage{tasks}

\geometry{left=1.5cm,right=7cm,top=2.5cm,bottom=1.5cm}

\begin{document}

\begin{tasks}[
  label=\bfseries\arabic*.,
  label-width=2em,
  label-align=right,
  start=31,
](2)
\task $x+y$ 
\task $x-y$
\task $a+b$ 
\task $a-b$
\task $u+v$
\task $u-v$
\end{tasks}

\begin{tasks}[
  label=\bfseries\arabic*.,
  label-width=2em,
  label-align=right,
  start=31,
](3)
\task $x+y$ 
\task $x-y$
\task $a+b$ 
\task $a-b$
\task $u+v$
\task $u-v$
\end{tasks}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .