在 tabularx 中模拟对齐环境,每个证明甚至多次

在 tabularx 中模拟对齐环境,每个证明甚至多次

我已经问过这个问题了:定义一个类似于 align 的环境,以便可以在 tabularx 或 tabular 中使用

Zarko 对这个问题的回答(https://tex.stackexchange.com/a/693393/277990)包括附录对于只有一组连续语句且其“=”符号水平对齐的情况,其代码给出了我想要的输出。

我希望允许存在多个此类组的情况。请参阅以下代码中的我的注释:

\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}

答案1

第二列应右对齐(朝向 =)并且数学如下:

在此处输入图片描述

\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}

相关内容