如何给页面内容添加边框

如何给页面内容添加边框

在此处输入图片描述\documentclass[letterpaper,10pt]{报告}

\newenvironment{packed_enum}{
\begin{enumerate}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{enumerate}}

\begin{document}

\chapter{Movies I need to watch}

Here is a short list of movies \marginpar{Flag A -- This note will appear in the margin.} I need to watch some day:

\begin{packed_enum}
   \item The Longest Day
   \item Kill Bill 1
   \item Kill Bill 2
   \item Pretty much every other movie created in the last 30 years. :)
\end{packed_enum}

\end{document}

答案1

您需要运行两次。它将 tikzpicture 位置存储在 aux 文件中。

\documentclass[letterpaper,10pt]{report}
\usepackage{everypage}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

\newenvironment{packed_enum}{
\begin{enumerate}
  \setlength{\itemsep}{1pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{enumerate}}

\newcommand{\myframe}{\begin{tikzpicture}[remember picture, overlay]
  \draw[blue,thick] ($(current page text area.south west) + (-2pt,-2pt)$) rectangle
    ($(current page text area.north east) + (2pt,2pt)$);
\end{tikzpicture}}% easier to debug
\AddEverypageHook{\myframe}

\begin{document}
\chapter{Movies I need to watch}

Here is a short list of movies \marginpar{Flag A -- This note will appear in the margin.} I need to watch some day:

\begin{packed_enum}
   \item The Longest Day
   \item Kill Bill 1
   \item Kill Bill 2
   \item Pretty much every other movie created in the last 30 years. :)
\end{packed_enum}

\end{document}

答案2

您可以使用eso-pic利用 shipout 例程(\AddToShipoutPictureFG-文档中每一页的F矿石轮),添加所需宽度:G\frame\AtPageCenter

在此处输入图片描述

\documentclass{article}

\usepackage{eso-pic,lipsum}

\AddToShipoutPictureFG{%
  \AtPageCenter{%
    \makebox[0pt]{\raisebox{-.5\height}{%
      \frame{%
        \rule{.9\paperwidth}{0pt}% Horizontal 0pt-width rule
        \rule{0pt}{.9\paperheight}% Vertical 0pt-width rule
      }
    }}%
  }%
}

\begin{document}

\lipsum[1-50]

\end{document}

\makebox[0pt]确保\frame水平设置在页面中间,而\raisebox{-.5\height}确保\frame垂直设置在页面中间。

相关内容