I have been using minipage environment with displayed equation environments align* and gather*. The align* environment works fine with minipage but does not work well with varwidth.
Code1:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{varwidth}
\begin{document}
\fcolorbox{blue}{white}{\begin{minipage}[t]{0.002\linewidth}
\begin{align*}
4x(x-5)&=0\\
4x=0\text{ or }x-5&=0\\
x=0\text{ or }x&=5.
\end{align*}
\end{minipage}}
\end{document}
Output1:
Code2:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{varwidth}
\begin{document}
\fcolorbox{blue}{white}{\begin{varwidth}[t]{0.002\linewidth}
\begin{align*}
4x(x-5)&=0\\
4x=0\text{ or }x-5&=0\\
x=0\text{ or }x&=5.
\end{align*}
\end{varwidth}}
\end{document}
Output2:
Note that, this
0.002\linewidthis supposed to be the minimum width.
The same problem happens when using gather* with either varwidth or minipage. Besides, the centering of the equation lines is messed up.
Code3:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{varwidth}
\begin{document}
\fcolorbox{blue}{white}{\begin{minipage}[t]{0.002\linewidth}
\begin{gather*}
4x(x-5)=0\\
4x=0\text{ or }x-5=0\\
x=0\text{ or }x=5.
\end{gather*}
\end{minipage}}
\end{document}
Code4:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{varwidth}
\begin{document}
\fcolorbox{blue}{white}{\begin{varwidth}[t]{0.002\linewidth}
\begin{gather*}
4x(x-5)=0\\
4x=0\text{ or }x-5=0\\
x=0\text{ or }x=5.
\end{gather*}
\end{varwidth}}
\end{document}
Outputs 3 and 4:
I can use the minipage since it's working with the align* environment. But I'd still need to have the gather* environment fixed.
I'm using LuaLaTeX output mode.
Please advise. :)




empheq, it works fine with bothalign*andgather*. But the package conflicts with other packages I'm using. – ένας Mar 26 '17 at 08:30empheqwithout loadingmathtoolswith it. – ένας Mar 26 '17 at 08:43mathtools? It's ‘only’ a very useful extension ofamsmath. – Bernard Mar 26 '17 at 11:09amsmath.) – barbara beeton Mar 26 '17 at 17:08