3

I would like to define an environment (called intermittentalign in the following code) that works like align but can work inside of tabularx (or inside of tabular would be okay too). How might I do this?

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

There seem to be similar questions already on StackExchange, but the answers to them don't spell things out enough that I can understand them.

Noah J
  • 515
  • 1
    Why don't you use an enumerate environment? – projetmbc Aug 14 '23 at 19:50
  • @projetmbc Do you mean merely to avoid having to number things manually, or are you hinting that there is a way to answer my question using enumerate? If the former, then my answer is that the reason I don't use enumerate here is that it won't work for the project I'm working on. (My MWE doesn't represent my project as a whole; it's geared toward the particular problem of my question.) – Noah J Aug 15 '23 at 01:55

2 Answers2

3

As far as I know, this is not possible on the way as you like to have. However, if you insert one more column, you can mimic align environment:

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

enter image description here

Addendum:
if I correctly understand OP comment below (but I'm not sure) he looking for something like this:

Edit:
Corrected error error in columns specification. Thanks to @David Carlisle who spotted it.

enter image description here

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

Zarko
  • 296,517
  • Is it possible to make the 'math' column flush left (but keep the "=3" aligned with the "=9/3", of course)? – Noah J Aug 14 '23 at 17:05
  • @NoahJ, all is possible, but it should be clear what you after. So far i do not understand what you after. Just word Math be left aligned? – Zarko Aug 14 '23 at 17:24
  • I would like for both the word 'Math' as well as 'm = 9/3' to be left-aligned, please. (I would like the '=' of '= 3' to be directly beneath the '=' of 'm = 9/3', as you have already done, of course --- that's what the whole business of mimicking align is about.) – Noah J Aug 14 '23 at 19:08
  • At the risk of asking too much, after you've already given such an excellent answer, is it possible to alter what you've written in the addendum so that it works for situations where two different sets of statements need their '=' symbols aligned? For example, if I were to add 4. & 34x+2 & = 30/2 & Words \\ 5. & & = 15 & Words \\ to what you have in the addendum, then all the '=' signs would be aligned with the '=' of line 4 (which isn't what one would want). – Noah J Aug 15 '23 at 18:07
  • 1
    @NoahJ, please ask new question. I'm bit confused what you after. Especially because, the context of your problem is unknown to me and probably I would try to solve what you like to present on the different way. – Zarko Aug 15 '23 at 18:17
  • I guess you meant r >$r<$ @{} >{\raggedright${}}X<{$} l for the last one so m is in math (but the OP posted a new question I anwered before seeing this) – David Carlisle Aug 15 '23 at 20:01
  • @DavidCarlisle, you are right. It seems that overlooked this when writing answer. It compile accidentally. Now corrected. I sow Your answer (+1)! – Zarko Aug 15 '23 at 20:13
3

This is not the syntax you desire, but one can use TABstacks to achieve the result.

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

enter image description here