4

I'm writing a script to extract LaTeX-generated images and save them as PDF files. I have an issue with too large images. This is my MWE:

\documentclass[varwidth]{standalone}
\usepackage{amsmath}
\begin{document}
  \setlength{\unitlength}{1cm}
  \begin{picture}(17,5)(-1.5,0)
    \thicklines
    \put(1.2,3.5){$x_7$}
    \put(1.2,1){$x_7$}
    \put(2,3.5){\line(2,-1){1}}
    \put(2,1){\line(2,1){1}}
    \put(3,1.5){\line(0,1){1.5}}
    \put(3,1.5){\circle*{0.15}}
    \put(3,3){\circle*{0.15}}
    \put(3,3){\line(2,1){1}}
    \put(3,1.5){\line(2,-1){1}}
    \put(4.2,3.5){$\theta^i$}
    \put(4.2,1){$\theta^j$}
    \put(3.2,2.2){$\theta$}
    \put(6,2.2){\bf+}
    \put(8.2,3.5){$x_7$}
    \put(8.2,1){$x_7$}
    \put(9,3.5){\line(2,-1){1}}
    \put(9,1){\line(2,1){1}}
    \put(10,1.5){\line(0,1){1.5}}
    \put(10,1.5){\circle*{0.15}}
    \put(10,3){\circle*{0.15}}
    \put(10,3){\line(1,-2){1}}
    \put(10,1.5){\line(1,2){1}}
    \put(11.2,3.5){$\theta^i$}
    \put(11.2,1){$\theta^j$}
    \put(9.6,2.2){$\theta$}
  \end{picture}
\end{document}

When I compile it with pdflatex I obtain a cut image:

enter image description here

Can I prevent it?

Gabriele
  • 1,815

1 Answers1

4

Just don't use varwidth, which is not necessary. The \setlength command belongs to the preamble.

The command \bf has been deprecated for 25 years

\documentclass{standalone}
\usepackage{amsmath}
\setlength{\unitlength}{1cm}
\begin{document}
\begin{picture}(17,5)(-1.5,0)
    \thicklines
    \put(1.2,3.5){$x_7$}
    \put(1.2,1){$x_7$}
    \put(2,3.5){\line(2,-1){1}}
    \put(2,1){\line(2,1){1}}
    \put(3,1.5){\line(0,1){1.5}}
    \put(3,1.5){\circle*{0.15}}
    \put(3,3){\circle*{0.15}}
    \put(3,3){\line(2,1){1}}
    \put(3,1.5){\line(2,-1){1}}
    \put(4.2,3.5){$\theta^i$}
    \put(4.2,1){$\theta^j$}
    \put(3.2,2.2){$\theta$}
    \put(6,2.2){\textbf{+}}
    \put(8.2,3.5){$x_7$}
    \put(8.2,1){$x_7$}
    \put(9,3.5){\line(2,-1){1}}
    \put(9,1){\line(2,1){1}}
    \put(10,1.5){\line(0,1){1.5}}
    \put(10,1.5){\circle*{0.15}}
    \put(10,3){\circle*{0.15}}
    \put(10,3){\line(1,-2){1}}
    \put(10,1.5){\line(1,2){1}}
    \put(11.2,3.5){$\theta^i$}
    \put(11.2,1){$\theta^j$}
    \put(9.6,2.2){$\theta$}
  \end{picture}
\end{document}

enter image description here

egreg
  • 1,121,712