使用以下示例:
\documentclass[]{article}
\usepackage{tikz,wrapfig,lipsum}
\begin{document}
\begin{wrapfigure}{r}{4cm}
\includegraphics[width=4cm]{fondo}
\caption{This figure looks ok, i.e. placed in the center with respect to the
caption}
\end{wrapfigure}
\lipsum[1-2]
\begin{wrapfigure}{r}{4cm}
\begin{tikzpicture}
\path(0,0) node(A){\includegraphics[width=4cm]{fondo}};
\end{tikzpicture}
\caption{This picture seems to be shift right, i.e. not in the center with respect
to the caption.}
\end{wrapfigure}
\lipsum[1-2]
\end{document}
我明白了:
我怎样才能修复第二个图形右侧的小偏移?
答案1
\documentclass[]{article}
\usepackage[demo]{graphicx} % remove the demo option in actual document.
\usepackage{tikz,wrapfig,lipsum}
%%% for the red border around the text. Do not use in actual document.
\usepackage{showframe}
\renewcommand*\ShowFrameColor{\color{red}}
\begin{document}
\begin{wrapfigure}{r}{4cm}
\includegraphics[width=4cm]{fondo}
\caption{This figure looks ok, i.e. placed in the center with respect to the
caption}
\end{wrapfigure}
\lipsum[1-2]
\begin{wrapfigure}{r}{4cm}
\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}] % <--------- added
\path(0,0) node(A){\includegraphics[width=4cm]{fondo}};
\end{tikzpicture}
\caption{This picture seems to be shift right, i.e. not in the center with respect
to the caption.}
\end{wrapfigure}
\lipsum[1-2]
\end{document}