1

I'm generating a .png image using the standalone class.

\documentclass[preview, border=0.5 pt, convert={size=650x650,outext=.png}]{standalone}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{braket}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{equation*}
p(x) = \sum_{i=0}^n a_ix^i, \quad q(x) = \sum_{j=0}^m b_ix^j, \quad m \ge n
\end{equation*}
\end{document}

and compiling with pdflatex --shell-escape formula.tex

The problem is that there is a lot of unused space in the image as you can see below compared to text,

https://i.imgur.com/hJlO2wdl.png

If I try to shrink the resolution of the x dimension it reduces as well the font size. Is there a way to optimize resolution vs font size?

1
  • The easy solution is to replace equation with $\displaystyle ...$. OTOH, I did not get a png, just the usual PDF. Commented Aug 31, 2020 at 14:50

1 Answer 1

1

The problem seems to be in the preview option that sets a fixed text width (which is what you observe as the borders). You can do without the fixed text width using normal $-delimited math, possibly with the \displaystyle macro to switch to "big" sum letters, as the comment suggested.

In particular, this seems to work just right:

\documentclass[border=5pt, convert={size=650x650,outext=.png}]{standalone}
\begin{document}
$\displaystyle
p(x) = \sum_{i=0}^n a_ix^i, \quad q(x) = \sum_{j=0}^m b_ix^j, \quad m \ge n $
\end{document}

PNG with the equation, border added manually using imagemagick

PS. You might want to consider using density instead of a fixed size, which may provide less surprising output in case of tiny or huge equations. In case you really need the equation* environment, you can put it in a minipage, but you need to guess the width manually:

\begin{minipage}{20em}
\begin{equation*}
p(x) = ...
\end{equation*}
\end{minipage}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .