仅显示页面的主框架

仅显示页面的主框架

我想打印一张白页,并在页面的主要部分带有框架:

  • 不是标题的框架

  • 不是页脚的框架

  • 不是脚注的框架

当我做

\documentclass[a4paper,10pt]{article}

\usepackage[margin=1.5cm, showframe]{geometry}
\pagestyle{empty}

\begin{document}
\
\end{document}

其余帧均已打印。请参见此屏幕截图左侧和底部的内容:

enter image description here

有没有解决办法,可以只打印主框架?

答案1

showframe选项使用一些规则来绘制框架。要坚持geometry,您需要重新定义代码showframe

\documentclass[a4paper,10pt]{article}

\usepackage[margin=1.5cm, showframe]{geometry}

\makeatletter
\renewcommand*{\Gm@vrules@mpi}{%
  \hb@xt@\@tempdima{\llap{\Gm@vrule}\ignorespaces
  \hskip \textwidth\Gm@vrule%\hskip \marginparsep
  % \llap{\Gm@vrule}%
  \hfil
  % \Gm@vrule%
  }}%
\renewcommand*{\Gm@vrules@mpii}{%
  \hb@xt@\@tempdima{\hskip-\marginparwidth\hskip-\marginparsep
  % \llap{\Gm@vrule}%
  \ignorespaces
  \hskip \marginparwidth
  % \rlap{\Gm@vrule}%
  \hskip \marginparsep
  \llap{\Gm@vrule}\hskip\textwidth\rlap{\Gm@vrule}\hss}}%
\renewcommand*{\Gm@pageframes}{%
  \vb@xt@\z@{%
   \ifGm@showcrop
    \vb@xt@\z@{\vskip-1\Gm@truedimen in\vskip\Gm@layoutvoffset%
     \hb@xt@\z@{\hskip-1\Gm@truedimen in\hskip\Gm@layouthoffset%
      \vb@xt@\Gm@layoutheight{%
       \let\protect\relax
       \hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,1,-3,3)\hfil\Gm@cropmark(1,1,3,3)}%
       \vfil
       \hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,-1,-3,-3)\hfil\Gm@cropmark(1,-1,3,-3)}}%
     \hss}%
    \vss}%
   \fi%
   \ifGm@showframe
    \if@twoside
     \ifodd\count\z@
       \let\@themargin\oddsidemargin
     \else
       \let\@themargin\evensidemargin
     \fi
    \fi
    \moveright\@themargin%
    \vb@xt@\z@{%
     \vskip\topmargin%\vb@xt@\z@{\vss\Gm@hrule}%
     \vskip\headheight%\vb@xt@\z@{\vss\Gm@hruled}%
     \vskip\headsep\vb@xt@\z@{\vss\Gm@hrule}%
     \@tempdima\textwidth
     \advance\@tempdima by \marginparsep
     \advance\@tempdima by \marginparwidth
     \if@mparswitch
      \ifodd\count\z@
       \Gm@vrules@mpi
      \else
       \Gm@vrules@mpii
      \fi
     \else
      \Gm@vrules@mpi
     \fi
     \vb@xt@\z@{\vss\Gm@hrule}%
     \vskip\footskip%\vb@xt@\z@{\vss\Gm@hruled}%
     \vss}%
    \fi%
  }}%
\makeatother

\pagestyle{empty}

\begin{document}
\
\end{document}

这是少量的代码。

含钛Z,,tikzpagenodes代码atbegshi变得更短一点;)

\documentclass[a4paper,10pt]{article}

\usepackage[margin=1.5cm]{geometry}

\usepackage{tikzpagenodes}

\usepackage{atbegshi}

\def\drawcode{%
\tikz [remember picture, overlay] \draw
  (current page text area.south west)
  rectangle
  (current page text area.north east);}

\AtBeginDocument{% For the first page
  \drawcode}

\AtBeginShipout{% For the remaining pages
  \drawcode}

\begin{document}
\
\end{document}

相关内容