我想定义一个环境(intermittentalign
在下面的代码中调用),它的工作方式类似于,align
但可以在其中工作tabularx
(或者在里面tabular
也可以)。我该怎么做?
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx}
\begin{document}
% Structure without intermittentalign (for comparison's sake):
\begin{tabularx}{250pt}{rXl}
1. & Math & Words\\
2. & Math & Words\\
3. & Math & Words
\end{tabularx}
% I would like something like this:
% \begin{tabularx}{250pt}{rXl}
% 1. & Math & Words\\
% 2. & \begin{intermittentalign} $ m &= 9/3 $ \end{intermittentalign} & Words\\
% 3. & \begin{intermittentalign} $ &= 3 $ \end{intermittentalign} & Words
% \end{tabularx}
% where the intermittentalign environment recalls the placement of & in previous intermittentalign environments
\end{document}
StackExchange 上似乎已经有类似的问题,但是它们的答案没有清楚地表达我所能理解的内容。
答案1
据我所知,这不可能如你所愿。但是,如果你再插入一列,你可以模拟align
环境:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{250pt}{r >{\raggedleft$}X<{$} @{\;} >{$\raggedright}X<{$} l}
1. & \multicolumn{2}{c}{Math}
& Words \\
2. & m = & 9/3 & Words \\
3. & = & 3 & Words \\
\end{tabularx}
\end{document}
附录:
如果我正确理解了下面的 OP 评论(但我不确定)他正在寻找这样的东西:
编辑:
已更正列规范中的错误。感谢发现此问题的@David Carlisle。
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{250pt}{r >{$}r<{$} @{\;} >{$\raggedright}X<{$} l}
1. & \multicolumn{2}{l}{Math}
& Words \\
2. & m & = 9/3 & Words \\
3. & & = 3 & Words \\
\end{tabularx}
\end{document}
答案2
这不是您想要的语法,但可以使用 TABstacks 来实现结果。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{tabstackengine}
\TABstackMath
\strutlongstacks{T}
\begin{document}
% Structure without intermittentalign (for comparison's sake):
\begin{tabularx}{250pt}{rXl}
1. & Math & Words\\
2. & Math & Words\\
3. & Math & more Words\\
4. & Math & final Words
\end{tabularx}
I would like something like this:
\begin{tabularx}{250pt}{rXl}
1. & Math & Words\\
\Longunderstack[r]{2.\\3.} &
\alignLongunderstack{m =& 9/3\\=& 3}&
\Longunderstack[l]{Words\\more Words}\\
4. & Math & final Words
\end{tabularx}
\end{document}