fixed columns in math mode
Hartmut Henkel
hartmut_henkel at gmx.de
Fri Sep 10 14:57:09 CEST 2021
Hi Karl,
On Fri, 10 Sep 2021, karl at aspodata.se wrote:
> 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.
only partial way forward, dirty: You could hijack the equation number,
since it's flush right, hopfefully not interfering with the formula
stuff, e. g. principally like this:
\documentclass{article}
\makeatletter
%\def\@eqnnum{{\normalfont \normalcolor (\theequation)}}
\def\etxt#1{\xdef\@eqnnum{{#1}}}
\def\noetxt{\def\@eqnnum{{\normalfont \normalcolor (\theequation)}}}
\makeatother
\begin{document}
\begin{eqnarray}
x & = & \sin(u) \etxt{bar}\\
y & = & \cos(u) \etxt{foo}
\end{eqnarray}
\noetxt
\begin{eqnarray}
x & = & \sin(u) \\
y & = & \cos(u)
\end{eqnarray}
\end{document}
Then you could style the \etxt macro for some fixed widths fitting the
items that should go there...
Best Regards, Hartmut
> 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.