在下面的代码中,标尺位于我想要的位置,即主体左侧/上方 19pt。但我希望每个 h 和 v 标尺上的 0 与主体的左上角重合。\fgrulerstartnumh{-19pt}
似乎是这样做的方法,但它只接受正整数。另一方面,如果我使用 []commented[-out]\usepackage
指令,我会得到第二个要求,但不会得到第一个要求。有没有办法摆脱这个困境?
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[type=none]{fgruler}
%\usepackage[type=upperleftT,unit=in]{fgruler}
\usepackage{xparse}
%https://tex.stackexchange.com/questions/588521/shifting-the-starting-number-of-a-ruler-such-that-0-aligns-with-the-top-left-cor
\ExplSyntaxOn
\makeatletter
% Adapted from:
% https://tex.stackexchange.com/questions/201488/how-to-get-the-active-left-and-right-margins-to-use-them-in-a-tikzpicture
\dim_new:N \erw_Gmlmargin_dim
\dim_set:Nn \erw_Gmlmargin_dim{\dimexpr\Gm@lmargin}
\dim_new:N \erw_Gmtmargin_dim
\dim_set:Nn \erw_Gmtmargin_dim{\dimexpr\Gm@tmargin}
\makeatother
\ExplSyntaxOff
\begin{document}
\ExplSyntaxOn
\noindent
\verb|\erw_Gmlmargin_dim|~
\dim_use:N\erw_Gmlmargin_dim;~
\verb|\erw_Gmtmargin_dim|:~\dim_use:N\erw_Gmtmargin_dim.\par
%\dim_new:N \erw_hstart_dim
%\dim_set:Nn\erw_hstart_dim{\dim_eval:n{-1 * 19pt}} % ERROR
\dim_zero_new:N \erw_hstart_dim
\dim_sub:Nn\erw_hstart_dim{19pt} % Workaround
\noindent{}\verb|\erw_hstart_dim|~\dim_use:N\erw_hstart_dim;~
\dim_zero_new:N \erw_vstart_dim
\dim_sub:Nn\erw_vstart_dim{19pt}
\noindent{}\verb|\erw_vstart_dim|~\dim_use:N\erw_vstart_dim.\par
\dim_new:N \erw_hshift_dim
\dim_set:Nn \erw_hshift_dim{\erw_Gmlmargin_dim}
\dim_add:Nn \erw_hshift_dim{\erw_hstart_dim}
\noindent{}\verb|\erw_hshift_dim|~\dim_use:N\erw_hshift_dim;~
\dim_new:N \erw_vshift_dim
\dim_set:Nn \erw_vshift_dim{\erw_Gmtmargin_dim}
\dim_add:Nn \erw_vshift_dim{\erw_hstart_dim}
\noindent{}\verb|\erw_vshift_dim|~\dim_use:N\erw_vshift_dim;~
% \fgrulerstartnumh{\erw_hstart_dim}
% \fgrulerstartnum{〈num〉}
% The〈num〉is a nonnegative integer, which will be the starting number on the horizontal and verticalrulers. Default:\fgrulerstartnum{0}
\fgruler[in]{upperleft}
{\erw_hshift_dim}
{\erw_vshift_dim}
\ExplSyntaxOff
\end{document}
答案1
也许这对你来说是正确的:
\documentclass{article}
\usepackage{lipsum}
\usepackage[type=user,unit=in,showframe,color=red]{fgruler}
\fgrulerdefuserin{
\rulerparamsfromfg
\AtTextLowerLeft{%
\rulernorotatenum
\fgrulercaptionin{}
\hspace{-5pt}\llap{\ruler[in]{downright}{\textheight}}}
\AtTextUpperLeft{%
\lower-5pt\hbox{\ruler[in]{rightdown}{\textwidth}}}}
\begin{document}
\lipsum
\end{document}