7

I'm interested in drawing a logo with Tikz to embed either as a PDF or as a code snippet in other Tex documents. In order to do this, I'd like to draw the logo in a small PDF file, size 1 inch by 1 inch. I try the following code and curiously, it seems that geometry has additional parameters influencing the shape of the PDF. What must I "set to zero" so that drawing a 1inch diameter circle intersects all edges of the PDF as viewed?

\documentclass{slides}
\usepackage[paperwidth=1in, paperheight=1in, margin=0in]{geometry}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw (0.5, 0.5) circle (1);
\end{tikzpicture}
\end{document}

2 Answers 2

8

Rather use

\documentclass{standalone}

Then you don't even need the geometry package. It automatically sets the size of the 'canvas' to the size of the bounding box.


Edit by percusse: Still, for the fun of it, you can get rid of the \hoffset and also you should make sure that the line width is also taken into account. Lastly, you need to use in instead of the default cm for the units.

\documentclass{article}
\usepackage[paperwidth=1in, paperheight=1in, margin=0in]{geometry}
\usepackage{tikz}
\setlength\hoffset{0in}
\begin{document}
\noindent\tikz\draw (0.5in+0.5pt,0.5in) circle (0.5in-0.25pt);
\end{document}
2
  • 1
    I've added a simple example. I hope you don't mind.
    – percusse
    Commented Jun 29, 2012 at 22:54
  • Thank you. Wasn't aware of the "standalone" doc class which was clearly what I should've been using. Interesting example with the use of hoffset and noindent additionally.
    – AdamO
    Commented Jun 30, 2012 at 19:16
1

You can also get a tight vector image by using preview package as follow.

enter image description here

\documentclass{article}
\usepackage{pstricks}

\usepackage[active,tightpage]{preview}
\PreviewBorder=12pt% you can set it to 0pt if you don't need a border.
\PreviewEnvironment{pspicture}


\begin{document}
\psset{unit=1in}% one unit equals to 1 inch.
\begin{pspicture}[showgrid](1,1)
    \pscircle[fillstyle=solid,fillcolor=yellow,opacity=0.5](0.5,0.5){0.5}
\end{pspicture}
\end{document}

You must log in to answer this question.

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