2

I'm a bit confused about what is a good way to insert a figure into a document. When you make an image for example from Tikz and then you want to export to PDF with some size (width, height) to insert into a document as it's faster than inserting Tikz directly.

Do you usually try to make the image size (width, height) matchs with the size of location you are going to put (y, x) as in the image below?

Or do you just draw the image in Tikz and export to whatever size you like and then scale when you insert into the target document?

enter image description here

6
  • Why scale at all (if it fits otherwise)? Related: Q6388 Dec 10, 2022 at 13:09
  • @Qrrbrbirlbel because you may not know exactly where you going to put the figure when you draw it. Like you just draw all figures and later put them in your document.
    – internet
    Dec 10, 2022 at 13:17
  • It's good if it fits but what if it doesn't fit? Can I just scale it or better to redraw it to make it fit? I just know that text doesn't scale properly so that is one reason not to scale. I don't know if there is other reasons.
    – internet
    Dec 10, 2022 at 13:22
  • Since TikZ produces a vector graphic (that is embedded as such in the produced PDF) there is absolutely no issue with scaling the included PDF, as long as you keep the image's aspect ratio in tact. As long as that is true, there should literally no difference from having the TikZ code directly in your main TeX (in terms of the output).
    – Raven
    Dec 10, 2022 at 15:32
  • 1
    scaling leads to bad font sizes and also affects line widths but can save one lots of time, so you will have to decide if your time or a perfect look is more important for you. Dec 11, 2022 at 11:54

1 Answer 1

1

I usually use the available linewidth as a parameter for creating the drawing.

Example:

\documentclass{article}

\usepackage{tikz}

\newcommand{\drawpicture}{%
\begin{tikzpicture}[x=1cm, y=1cm]
    \pgfmathsetmacro{\lw}{\linewidth/1cm}
    
    \begin{scope}[x=\lw cm, y=0.3*\lw cm]
        \draw[->] (0,0) -- (1,0) node [below] {$\omega$};
        \draw[->] (0.05,-0.25) -- +(0,1) node [left] {$M$};
        \draw (0.05,0.5) -- ++(0.5,0) -- ++(0.4,-0.75);
        
        \begin{scope}[yshift=-0.15*\lw cm]
            \draw[->] (0,0) -- (1,0) node [below] {$\omega$};
            \draw[->] (0.05,-0.5) -- +(0,0.6) node [left] {$\phi$};
            \draw (0.05,-0.05) -- ++(0.4,0) -- ++(0.2,-0.5) -- ++(0.3,0);
        \end{scope}
    \end{scope}
\end{tikzpicture}%
}

\begin{document}
\foreach \x in {0.25,0.5,0.75,1} {%
    \begin{minipage}{\x\linewidth}
        \drawpicture
    \end{minipage}\\
}
\end{document}

enter image description here

You must log in to answer this question.

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