0

I have already asked this question: Define an environment similar to align such that it can be used in tabularx or tabular.

Zarko's answer to that question (https://tex.stackexchange.com/a/693393/277990) includes an Addendum whose code gives exactly the output I want for situations in which there is only one group of successive statements whose '=' symbols are horizontally aligned.

I would like to allow for situations in which there is more than one such group. Please see my remarks in the following code:

\documentclass{article}
\usepackage{tabularx}

\begin{document}

% The code given in the Addendum to Zarko's answer:

\begin{tabularx}{250pt}{r l @{;} >{$\raggedright}X<{$} l}

  1. & \multicolumn{2}{l}{Math} & Words \
  2. & m & = 9/3 & Words \
  3. & & = 3 & Words \

\end{tabularx}

\vspace{1cm}

The above code is succcessful. However, it cannot cope with situations in which there are two or more different groups of successive statements requiring separate horizontal alignments of = symbols. For example, look what happens to the output if we keep going (e.g. if we add lines 4 and 5 to the above):

\vspace{1cm}

\begin{tabularx}{250pt}{r l @{;} >{$\raggedright}X<{$} l}

  1. & \multicolumn{2}{l}{Math} & Words \
  2. & m & = 9/3 & Words \
  3. & & = 3 & Words \
  4. & 34x+2 & = 30/2 & Words \
  5. & & = 15 & Words \

\end{tabularx}

\vspace{1cm}

We see that the horizontal alignment of all four =' symbols is determined by the=' symbol in line 4, whereas what we want is for the =' symbol in line 3 to be aligned with the=' symbol in line 2 and for the =' symbol in line 5 to be aligned with the=' symbol in line 4. In other words, we want to eliminate the space between m' and= 9/3', and then align the =' symbol in line 3 directly below the=' symbol in line 2.

\end{document}

Noah J
  • 515

1 Answers1

2

The second column should be right aligned (towards the =) and math so one of these:

enter image description here

\documentclass{article}
\usepackage{tabularx}

\begin{document}

The above code is succcessful. However, it cannot cope with situations in which there are two or more different groups of successive statements requiring separate horizontal alignments of = symbols. For example, look what happens to the output if we keep going (e.g. if we add lines 4 and 5 to the above):

\vspace{1cm}

\begin{tabularx}{250pt}{r >$r<$ @{} >{\raggedright${}}X<{$} l}

  1. & \multicolumn{2}{l}{Math} & Words \
  2. & m & = 9/3 & Words \
  3. & & = 3 & Words \
  4. & 34x+2 & = 30/2 & Words \
  5. & & = 15 & Words \

\end{tabularx}

\vspace{1cm}

\begin{tabularx}{250pt}{r >$r<$ @{} >{\raggedright${}}X<{$} l}

  1. & \multicolumn{2}{l}{Math} & Words \
  2. & m & = 9/3 & Words \
  3. & & = 3 & Words \

\end{tabularx}

\begin{tabularx}{250pt}{r >$r<$ @{} >{\raggedright${}}X<{$} l} 4. & 34x+2 & = 30/2 & Words \ 5. & & = 15 & Words \ \end{tabularx}

\vspace{1cm}

We see that the horizontal alignment of all four =' symbols is determined by the=' symbol in line 4, whereas what we want is for the =' symbol in line 3 to be aligned with the=' symbol in line 2 and for the =' symbol in line 5 to be aligned with the=' symbol in line 4. In other words, we want to eliminate the space between m' and= 9/3', and then align the =' symbol in line 3 directly below the=' symbol in line 2.

\end{document}

David Carlisle
  • 757,742