答案1
答案2
您有多个未受保护的行尾,它们算作空格:
{%
\setlength{\fboxsep}{5px}%
\setlength{\fboxrule}{3px}%
\noindent\makebox[\linewidth]{%
\fbox{%
{%
\setlength{\fboxsep}{3px}%
\setlength{\fboxrule}{1px}%
\fbox{%
\includegraphics[scale=1.0]{test.png}%
}%
}%
}%
}%
}
这里有一个实现,允许分别指定规则厚度和间隔。内部\ExplSyntaxOn
空格和行尾将被忽略。
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\doublefbox}{ O{} m }
{
\group_begin:
\keys_set:nn { kontextify/doublefbox } { #1 }
\kontextify_doublefbox:n { #2 }
\group_end:
}
\keys_define:nn { kontextify/doublefbox }
{
rule1 .dim_set:N = \l__kontextify_ruleone_dim,
rule2 .dim_set:N = \l__kontextify_ruletwo_dim,
sep1 .dim_set:N = \l__kontextify_sepone_dim,
sep2 .dim_set:N = \l__kontextify_septwo_dim,
rule1 .initial:n = \fboxrule,
rule2 .initial:n = \fboxrule,
sep1 .initial:n = \fboxsep,
sep2 .initial:n = \fboxsep,
}
\cs_new_protected:Nn \kontextify_doublefbox:n
{
\dim_set:Nn \fboxrule { \l__kontextify_ruleone_dim }
\dim_set:Nn \fboxsep { \l__kontextify_sepone_dim }
\fbox
{
\dim_set:Nn \fboxrule { \l__kontextify_ruletwo_dim }
\dim_set:Nn \fboxsep { \l__kontextify_septwo_dim }
\fbox
{
#1
}
}
}
\ExplSyntaxOff
\begin{document}
\doublefbox{\rule{1cm}{1cm}}
\bigskip
\doublefbox[rule1=1pt,sep1=3pt]{\rule{1cm}{1cm}}
\bigskip
\doublefbox[rule1=1pt,sep1=3pt,rule2=3pt,sep2=5pt]{\rule{1cm}{1cm}}
\end{document}