答案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}