在这个 MWE 中,\myfig
似乎水平移动了一半\pgflinewidth
:
\documentclass{article}
\usepackage{tikz}
\def\myfig{\includegraphics[height=1cm, width=\linewidth]{example-image-a4-numbered}}
% just fooling around:
\begin{document}
Reference:\\
\myfig
This works:\\
\begin{tikzpicture}
\draw (0,0) node[inner sep=0] { \myfig };
\end{tikzpicture}
Overfull hbox (about 0.4pt too wide):\\
\begin{tikzpicture}
\draw (0,0) node[inner sep=0, anchor=south west] { \myfig };
\end{tikzpicture}
Overfull hbox (about 0.2pt too wide):\\
\begin{tikzpicture}
\draw (0,0) node[inner sep=0, anchor=south west, outer xsep=0] { \myfig };
\end{tikzpicture}
Overfull hbox (about 2pt too wide):\\
\begin{tikzpicture}
\pgfsetlinewidth{10\pgflinewidth}
\draw (0,0) node[inner sep=0, anchor=south west, outer xsep=0] { \myfig };
\end{tikzpicture}
Workaround:\\
\begin{tikzpicture}
\pgfsetlinewidth{100\pgflinewidth}
\draw (0,0) node[inner sep=0, anchor=south west, outer xsep=-\pgflinewidth/2] { \myfig };
\end{tikzpicture}
\end{document}
有没有比我正在使用的更好的解决方法?