Do you make image size match with the size of the image in the target document?

Do you make image size match with the size of the image in the target document?

我有点困惑,不知道在文档中插入图片的最好方法是什么。例如,当您从 Tikz 制作图像,然后想要导出为具有一定大小的 PDF(width, height)以插入文档时,这比直接插入 Tikz 更快。

您是否通常会尝试使图像大小(width, height)与您要放置的位置的大小相匹配,(y, x)如下图所示?

或者您只是在 Tikz 中绘制图像并导出为您喜欢的任意大小,然后在插入目标文档时缩放?

enter image description here

答案1

我通常使用可用linewidth作为创建绘图的参数。

例子:

\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

相关内容