3

I am attempting to use latex to generate images of mathematical equations using the standalone environment. I wish to force the subscript and superscript to appear below and above the sum respectively in the manner of the following. enter image description here However, my code currently produces. enter image description here My code is as follows.

\documentclass{standalone}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{bm}
\usepackage{pagecolor}
\definecolor{byellow}{RGB}{255, 255, 0}
\begin{document}
\pagecolor{black}
\textcolor{byellow}
\[\displaystyle\pbm{\bm{\zeta \left(z\right) = {\sum}_{n = 1}^{\infty} \frac{1}{{n}^{s}}}}\]
\end{document}
4
  • 2
    Did you try removing the pair of braces around \sum? Also, \displaystyle is not necessary in a displayed equation.
    – Bernard
    Commented Jun 20, 2022 at 20:53
  • 1
    @Bernard the issue is not extra braces (although, yes, they are redundant). standalone environment redefines equation environment, so you need inline math and a manual displaystyle. See my answer. Commented Jun 20, 2022 at 21:04
  • 2
    In this case, another suggestion: try with \sum\limits_{n=1}^{\infty}.
    – Bernard
    Commented Jun 20, 2022 at 21:08
  • 1
    About the math consistence itself: Riemann's zeta function is normally written as \zeta(s) instead of \zeta(z), s is the variable inside the sum over n. I know both zand s are used as complex variables, but I must immediately ask when I see some inconsistency. Sorry for pointing it out.
    – FHZ
    Commented Jun 20, 2022 at 21:37

4 Answers 4

3

With no option, standalone uses horizontal mode: basically you have to think that the document body is typeset in a \mbox.

Indeed, your code produces errors. First error, \[ is taken as argument to \textcolor, which wants two arguments. Second error: ! Missing $ inserted. which is typical for \[...\] inside \mbox.

You can use $\displaystyle...$ instead.

If you want the formula to be bold, don't use \bm nor \pmb (the latter makes for very dubious output). Simply issue \boldmath. The summation symbol would not be bold, though.

You can fix it by declaring the bold version for cmex.

\documentclass{standalone}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{pagecolor}

\definecolor{byellow}{RGB}{255, 255, 0}

\DeclareFontShape{OMX}{cmex}{b}{n}{<-> cmexb10}{}
\SetSymbolFont{largesymbols}{bold}{OMX}{cmex}{b}{n}

\begin{document}
\pagecolor{black}%<--- don't forget
\color{byellow}%<--- don't forget
\boldmath
$\displaystyle\zeta(s) = \sum_{n = 1}^{\infty} \frac{1}{n^{s}}$
\end{document}

enter image description here

Without the two font declarations you'd get

enter image description here

so you see that in the previous image the summation symbol is indeed bold.

For a further comparison, here's the output if \boldmath is omitted.

enter image description here

And also the output of the summation without the font declarations and using \pmb: not really what I'd like to see in my document.

enter image description here

Note that I removed several parts from your code: mainly \left and \right that only add unwanted space; also some braces that ruin the typesetting. And s instead of z.

1
  • Good as ever! My own personal preference, since this is a personal project where you can use any fonts and packages you want, would be to use modern fonts and unicode-math. The \boldmath (or \boldsymbol{...}) commands will still work, and you can \setmathfont[bersion=bold, FakeBold=1.2] if desired.
    – Davislor
    Commented Jun 21, 2022 at 2:25
5

minipage can restore the display style.

\documentclass[12pt]{standalone}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{pagecolor}
\pagecolor{black}
\begin{document}
\begin{minipage}{26mm}
\color{yellow}\abovedisplayskip=0pt\relax
\[
\zeta (z) = \sum_{n = 1}^\infty \frac{1}{n^s}
\]
\end{minipage}
\end{document}

enter image description here

3

Use inline math with manual \displaystyle in standalone document class.

standalone class seems to redefine equation environment: https://tex.stackexchange.com/a/50171/97712 .

Here is your MWE:

\documentclass{standalone}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{xcolor}
\usepackage{pagecolor}

\definecolor{byellow}{RGB}{255, 255, 0}

\begin{document}

    \pagecolor{black}
    \color{byellow}
    
    $\displaystyle
        \bm{
            \zeta \left( z \right) = \sum_{n = 1}^\infty \frac{1}{ n^s }
        }
    $
    
\end{document}

enter image description here

0
\documentclass{standalone}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{xcolor}
\usepackage{pagecolor}

\definecolor{byellow}{RGB}{255, 255, 0}

\begin{document}

    \pagecolor{black}
    \color{byellow}
    
    $\displaystyle
        \bm{
            \zeta \left( z \right) = \sum_{n = 1}^\infty \frac{1}{ n^s }
        }
    $
    
\end{document}

You must log in to answer this question.

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