TransWikia.com

standalone class would not crop AMS equations properly (left and top margin space remains)

TeX - LaTeX Asked on July 25, 2021

I have the following simple code that I thought would output the AMS “gather” equation properly cropped at all sides up to the point where an imaginary straight line drawn at each side would touch the contents of the equation (enclosing it in imaginary box without leaving any spaces). But for some reason there is a big uncropped space on the left and top sides as well as a little one at the right side.

documentclass[fleqn,varwidth]{standalone}
usepackage{amsmath}

begin{document}
begin{gather*}
2^{1}=binom{1}{0}+binom{1}{1}
2^{2}=binom{2}{0}+binom{2}{1}+binom{2}{2}
end{gather*}
end{document}

big left and top-side space remains as well as small right-side space

Here I highlight the spaces I don’t want standalone class to output

enter image description here

Your help with modifying the code to make this unwanted spaces go away is greatly appreciated.

Thanks

2 Answers

I think you need an output that does not span across multiple page then converting displayed equations to inline equations.

documentclass[margin=1pt]{standalone}
usepackage{amsmath}

begin{document}
$!
begin{gathered}
2^{1}=binom{1}{0}+binom{1}{1}
2^{2}=binom{2}{0}+binom{2}{1}+binom{2}{2}
end{gathered}
$
end{document}

enter image description here

Notes:

  • margin of 1 pt is optionally added, remove it if you do not need it.

  • ! is important to remove the unnecessary whitespace.

  • use displayequation after the opening $ if you need displayed version of "font".

The above is for gathered, for aligned see the following.

documentclass[margin=1pt]{standalone}
usepackage{amsmath}

begin{document}
$!
begin{aligned}
2^{1}&=binom{1}{0}+binom{1}{1}
2^{2}&=binom{2}{0}+binom{2}{1}+binom{2}{2}
end{aligned}
$
end{document}

enter image description here

Correct answer by Who Save Me Save Entire World on July 25, 2021

You can do it with a TABstack, using the new and improved tabstackengine package (2016-10-04).

documentclass[varwidth]{standalone}
usepackage{amsmath}
usepackage{tabstackengine}[2016-10-04]
TABstackMath
TABstackMathstyle{displaystyle}
setstackgap{S}{6pt}
begin{document}
alignShortstack{
2^{1}=&binom{1}{0}+binom{1}{1}
2^{2}=&binom{2}{0}+binom{2}{1}+binom{2}{2}
}!
end{document}

enter image description here

Answered by Steven B. Segletes on July 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP