fixed columns in math mode

karl at aspodata.se karl at aspodata.se
Fri Sep 10 14:22:14 CEST 2021


Any ideas how to solve the problem below or how to find a nicer
solution ?

I'm trying to write some text with formulas interspaced with comments,
but i want to have the equalsign (or something else) and possible some
if's (at right) at the same "columns" in the text.

See e.g. page 11 and 14 of the current result:
 http://aspodata.se/tmp/voltage_inverter.pdf
with source in:
 http://aspodata.se/git/openhw/text/switched_power/

///

Is there any \makebox-like thing that works in math mode so I can set the
contents width, or rather where the next thing will land ?

///

I have tried with the array, IEEEeqnarray and some other environments
but they didn't do what I wanted so I came up with

\newcommand*{\eqnline}[4]{%
\makebox[\widthA]{$\hfill\displaystyle{#1}$}%
{$\:\displaystyle{#2}\:$}%
\makebox[\widthB]{$\displaystyle{#3}$\hfill }%
$\displaystyle{#4}$%
}

That way I can have
. the "=" and the if's (#2, #4) at the same position
. the "between" equations text at left, just where ordinary text is
. page breaks can happen between equation lines just as it does for
  ordinary text

There is a problem with this, since the line ends doesn't know about
\displaystyle{} (my guess), so I have to add \\[1ex] and similar.

///

And I cannot figure out how to make a macro of

\makebox[\widthA]{$\hfill\displaystyle{\max i_L}$}%
{$\:\displaystyle{=}\:$}%
{$\left\{
\begin{array}{l}
%\makebox[\widthB]{$\displaystyle{A}$\hfill }deldrift\\[1ex]
\text{\makebox[\widthC]{$\displaystyle{- I_B P_B}$\hfill }deldrift}\\[1ex]
\text{\makebox[\widthC]{$\displaystyle{- I_{LPP}}$\hfill }gränsdrift}\\[1ex]
\text{\makebox[\widthC]{$\displaystyle{- \frac{I_{LPP}}{2} + \frac{-I_{ut}}{P_B}}$\hfill }heldrift}\\[1ex]
\end{array}
\right.$}\\[1ex]

I.e. something similar to:

\begin{equation*}
 |x| =
 \begin{cases}
   -x & \text{if } x < 0,\\
    0 & \text{if } x = 0,\\
    x & \text{if } x > 0.
 \end{cases}
\end{equation*}

Regards,
/Karl Hammar




More information about the tex-live mailing list.