迷你页面中的填充

迷你页面中的填充

我建立了一个带有一些背景图片的小页面:

\newsavebox\langscapeSafebox
\newenvironment{dsaBoxLandscape}[1][]{%
\def\imgcmd{\includegraphics[width=\wd\langscapeSafebox,height=\dimexpr\ht\langscapeSafebox+\dp\langscapeSafebox\relax,#1]{images/box-landscape.png}}%
   \begin{lrbox}{\langscapeSafebox}%
   \begin{minipage}%
}{%
   \end{minipage}
   \end{lrbox}%
   \sbox\langscapeSafebox{\usebox\langscapeSafebox}%
   \mbox{\rlap{\raisebox{-\dp\langscapeSafebox}{\imgcmd}}\usebox\langscapeSafebox}%
}

% somewhere in the document:

\begin{dsaBoxLandscape}{14cm}
   Some content
\end{dsaBoxLandscape}

现在我想在小页面的每一侧(上、下、左、右)添加一些填充,以便内容不会与背景图像的样式边框部分重叠。我该怎么做?

答案1

我已在 大小中添加了填充\fboxsepdraft选项是仅显示框架而不是图像,字符串duck.jpg只是我用于示例的文件名。

填充位于左边距之外,如果您想将内框推到右方,请删除并在之前\hspace{-\fboxsep}添加。\hspace{\fboxsep}\usebox

我删除了无用的东西\sbox{\langscapeSafebox}{\usebox{\langscapeSafebox}},只是将盒子重置为自身。

\documentclass{article}
\usepackage{lipsum} % just for the example
\usepackage[draft]{graphicx} % draft is just for the example

\newsavebox\langscapeSafebox
\newenvironment{dsaBoxLandscape}[2][]{%
  \def\imgcmd{%
    \includegraphics[
      width=\dimexpr\wd\langscapeSafebox+2\fboxsep\relax,
      height=\dimexpr\ht\langscapeSafebox+\dp\langscapeSafebox+2\fboxsep\relax,
      #1
    ]{images/box-landscape.png}}%
  \begin{lrbox}{\langscapeSafebox}%
  \begin{minipage}{#2}
}{%
   \end{minipage}
   \end{lrbox}%
   \noindent
   \makebox[0pt][l]{%
     \hspace{-\fboxsep}%
     \raisebox{\dimexpr-\dp\langscapeSafebox-\fboxsep}{\imgcmd}%
   }%
   \usebox\langscapeSafebox
}

\begin{document}

\lipsum[2]

\begin{dsaBoxLandscape}{\textwidth}
Some content

and some other
\end{dsaBoxLandscape}

\lipsum[3]

\end{document}

在此处输入图片描述

相关内容