3

I am using the \documentclass option [fleqn] (which I think is identical to \usepackage[fleqn]{amsmath}). This seems to work fine, except when using an align* within the varwidth environment:

enter image description here

Notes:

  • Problem does not occur with align (non-starred) environment.

Code

\documentclass[fleqn]{article}
\usepackage{showframe}
\usepackage{varwidth}
\usepackage{mathtools}

\newcommand*{\MyContent}{%
Using align*:
\begin{align*}
    E &= mc^2
    \shortintertext{and}
    F &= ma
\end{align*}%
Using align
\begin{align}
    y = x + b
\end{align}%
}%

\begin{document}
\noindent
Outside of \verb|varwidth|:

\MyContent

\noindent
Inside \verb|varwidth|:

\noindent
\begin{varwidth}{\linewidth}
    \MyContent
\end{varwidth}
\end{document}
3

You just need to set the flag in the documented high level varwidth interface.

enter image description here

\documentclass[fleqn]{article}
\usepackage{showframe}
\usepackage{varwidth}
\usepackage{mathtools}

\newcommand*{\MyContent}{%
Using align*:
\begin{align*}
    E &= mc^2
    \shortintertext{and}
    F &= ma
\end{align*}%
Using align
\begin{align}
    y = x + b
\end{align}%
}%

\makeatletter\let\@vwid@eqmodetrue\@vwid@eqmodefalse\makeatother
\begin{document}
\noindent
Outside of \verb|varwidth|:

\MyContent

\noindent
Inside \verb|varwidth|:

\noindent vw\\
\begin{varwidth}{\linewidth}
    \MyContent
\end{varwidth}

\noindent mp\\
\begin{minipage}{\linewidth}
    \MyContent
\end{minipage}

\end{document}
| improve this answer | |
  • 1
    "Documented?" :-) texdoc varwidth opens up a one page document!! I guess you have access to better documentation. :-). Thanks for the fix. – Peter Grill Oct 6 '17 at 18:36
  • @PeterGrill note that this isn't really a "fix" that is you couldn't generally patch the package in this way. varwidth failed to understand align* so it decided this was a centred equation and re-centred it, the patch disables that test so it never decides that it was a centred equation. This wouldn't be correct if you were not using fleqn and needed that test. – David Carlisle Oct 6 '17 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.