由于某种原因,当我尝试将图像应用到页面时,图像左侧会出现白色边缘。如何去除它?
我已经为您创建了一个最小代码示例:)
\documentclass{article}
\usepackage{tikz}
\RequirePackage[framemethod=TikZ]{mdframed}
%=========================================================================
% Image with border
%=========================================================================
% Arguments:
% 1) Optional image parameter like height or width
% 2) Optional border parameters
% 3) Image path
% 4) Caption
% 5) Label
\newsavebox\framedImageBox
\NewDocumentCommand{\framedImage}%
{O{width=0.6\linewidth}
O{draw=black,line width=0.75pt,rounded corners=20pt}
m
m
m}{%
\begin{figure}
\centering
\savebox\framedImageBox{
\includegraphics[#1]{#3}}%
\begin{tikzpicture}%
\draw [path picture={%
\node at (path picture bounding box.center) {%
\usebox\framedImageBox};},#2]%
(0,0) rectangle (\wd\framedImageBox,\ht\framedImageBox);
\end{tikzpicture}%
\caption{#4}
\label{#5}
\end{figure}
}
\begin{document}
\framedImage[width=0.8\linewidth]{summer}{a summer day.}{fig:a_summer_day}
\end{document}
答案1
在我看来,你错过%
了
\savebox\framedImageBox{
添加%
应该会消除边距!
\documentclass{article}
\usepackage{tikz}
\RequirePackage[framemethod=TikZ]{mdframed}
%=========================================================================
% Image with border
%=========================================================================
% Arguments:
% 1) Optional image parameter like height or width
% 2) Optional border parameters
% 3) Image path
% 4) Caption
% 5) Label
\newsavebox\framedImageBox
\NewDocumentCommand{\framedImage}%
{O{width=0.6\linewidth}
O{draw=black,line width=0.75pt,rounded corners=20pt}
m
m
m}{%
\begin{figure}
\centering
\savebox\framedImageBox{% Here!!!!
\includegraphics[#1]{#3}}%
\begin{tikzpicture}%
\draw [path picture={%
\node at (path picture bounding box.center) {%
\usebox\framedImageBox};},#2]%
(0,0) rectangle (\wd\framedImageBox,\ht\framedImageBox);
\end{tikzpicture}%
\caption{#4}
\label{#5}
\end{figure}
}
\begin{document}
\framedImage[width=0.8\linewidth]{summer}{a summer day.}{fig:a_summer_day}
\end{document}