提高或降低 \hrulefill

提高或降低 \hrulefill

我正在编辑一份使用\hrulefill“字段”作为文本输入的调查问卷。

我想将\hrulefill稍微降低一点,以便为参与者提供更多书写空间。对于固定长度规则,我会使用类似 的内容。我可以以类似的方式\rule[-3pt]{#1}{0.6pt}提高或降低或将填充行为添加到吗?\hrulefill\rule

Please state your name: \hrulefill
I was born on \hrulefill in \hrulefill
...

在此处输入图片描述

答案1

您可能想看看这个包。这是一个使用键/值语法定义规则位置的xhfill版本。xparse

您可以height指定规则相对于基线的底部位置(默认 0pt);thickness规则的厚度(默认 0.4pt);fill行为(默认\fill)。

特别地,\xhrulefill没有参数的 等同于\hrulefill

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\xhrulefill}{O{}}
 {
  \group_begin:
  \severin_xhrulefill:n { #1 }
  \group_end:
 }

\keys_define:nn { severin/xhrulefill }
 {
  height .dim_set:N    = \l_severin_xhrule_height_dim,
  thickness .dim_set:N = \l_severin_xhrule_thickness_dim,
  fill .skip_set:N     = \l_severin_xhrule_fill_skip,
  height .initial:n    = 0pt,
  thickness .initial:n = 0.4pt,
  fill .initial:n      = 0pt plus 1fill,
 }

\cs_new_protected:Nn \severin_xhrulefill:n
 {
  \keys_set:nn { severin/xhrulefill } { #1 }
  \leavevmode
  \leaders\hrule 
    height \dim_eval:n { \l_severin_xhrule_thickness_dim + \l_severin_xhrule_height_dim }
    depth  \dim_eval:n { -\l_severin_xhrule_height_dim }
  \skip_horizontal:N \l_severin_xhrule_fill_skip
  \kern 0pt
}
\ExplSyntaxOff

\setlength{\textwidth}{6cm} % just for the test

\begin{document}

abc\hrulefill

abc\xhrulefill

abc\xhrulefill[height=-3pt]

abc\xhrulefill[height=-2pt,thickness=1pt,fill=3cm]

abc\xhrulefill[height=-3pt,thickness=1pt]

abx\xhrulefill[height=0pt,thickness=1ex]

\end{document}

在此处输入图片描述

答案2

您可以将您的物品放入以下盒子\hrulefill中:\vtop

\documentclass[10pt,letterpaper]{article}

\begin{document}
    Please state your name: \hrulefill

    I was born on \hskip-1em\vtop{\vskip.05cm\hsize=2in \hrulefill}%
    ~~in \hskip-1em\vtop{\vskip.05cm\hsize=2in \hrulefill}

\end{document}

在此处输入图片描述

您可以使用宏做同样的事情:

\documentclass[10pt,letterpaper]{article}

\def\Lrule#1#2{\vtop{\vskip#1\hsize=#2 \hrulefill}}

\begin{document}
    Please state your name: \hrulefill

    I was born on\hskip-1em\Lrule{.05cm}{2in}~~in%
     \hskip-1em\Lrule{.05cm}{2in}

\end{document}

但是,上述代码要求指定线长,因此不能起到粘合的作用,\hrulefill因为它没有胶水。

使用引线的另一种方法。这次控制序列的作用类似于,\hrulefill但相对于基线(第一个变量)具有可变的高度。它使用重复字符来生成线(第二个变量):

\documentclass[10pt]{article}

\def\Vrulefill#1#2{
    \leavevmode%
    \hskip-.2in%
    \leaders%
    \vtop{\hsize=.0025in\vskip#1#2}%
    \hfill%
    \hskip.3in%
}

\begin{document}



  %%With Zero \vskip and the period as the repeated character%%
  \Vrulefill{0in}{.}Hello Kitty\Vrulefill{0in}{.}Hello Kitty\Vrulefill{.02in}{.}%
Hello Kitty \vskip.1in

 %%With Zero \vskip and the \_ as the repeated character%%
  \Vrulefill{0in}{\_}Hello Kitty\Vrulefill{0in}{\_}Hello Kitty\Vrulefill{0in}{\_}%
Hello Kitty \vskip.1in

  %%With Zero \vskip and the dash as the repeated character%%
  \Vrulefill{0in}{-}Hello Kitty\Vrulefill{0in}{-}Hello Kitty\Vrulefill{0in}{-}%
Hello Kitty

  \vskip.5in

  %%With .05in \vskip and the period as the repeated character%%
  \Vrulefill{.05in}{.}Hello Kitty\Vrulefill{.05in}{.}Hello Kitty\Vrulefill{.05in}{.}%
Hello Kitty \vskip.1in

   %%With .05in \vskip and the \_ as the repeated character%%  
  \Vrulefill{.05in}{\_}Hello Kitty\Vrulefill{.05in}{\_}Hello Kitty\Vrulefill{.05in}{\_}%
Hello Kitty \vskip.1in

   %%With .05in \vskip and the dash as the repeated character%%
  \Vrulefill{.05in}{-}Hello Kitty\Vrulefill{.05in}{-}Hello Kitty\Vrulefill{.05in}{-}%
Hello Kitty
      \vskip.5in

     %%With negative .05in \vskip and the period as the repeated character%%
    \Vrulefill{-.05in}{.}Hello Kitty\Vrulefill{-.05in}{.}Hello Kitty\Vrulefill{-.05in}{.}%
Hello Kitty \vskip.1in

    %%With negative .05in \vskip and the dash as the repeated character%%
    \Vrulefill{-.05in}{\_}Hello Kitty\Vrulefill{-.05in}{\_}Hello Kitty\Vrulefill{-.05in}{\_}%
Hello Kitty \vskip.1in

   %%With negative .05in \vskip and the dash as the repeated character%%
    \Vrulefill{-.05in}{-}Hello Kitty\Vrulefill{-.05in}{-}Hello Kitty\Vrulefill{-.05in}{-}%
Hello Kitty


\end{document}

其结果为:

在此处输入图片描述

改变

`\vtop{\hsize=.0025in\vskip#1#2}%

到:

`\vtop{\hsize=.05in\vskip#1#2}%`

给你一些非常漂亮的点线和虚线:

在此处输入图片描述

并使用相同的\vtop{\hsize=.05in\vskip#1#2}%

\Vrulefill{0in}{/}
            \vskip.2in

    \Vrulefill{0in}{@}
                \vskip.2in

     \Vrulefill{0in}{[]}
              \vskip.2in

    \Vrulefill{0in}{\}\{}

可以产生一些有趣的装饰规则:

在此处输入图片描述

可以使用\vline作为“字符”来制作粗线和细线或虚线:

     \Vrulefill{0in}{\vline height .2em width 4pt}

     \Vrulefill{0in}{\vline height .001em width 4pt}

在此处输入图片描述

答案3

这里我使用引线来提供\drulefill(虚线填充),有 4 个控制参数:

\ruleht仪表板的高度是多少,这个问题的原作者想要控制什么

\repfrac是介于 0 和 1 之间的分数(含 0 和 1),表示虚线的实线分数。通过设置值 = 1,虚线将变为实线,这正是 OP 想要的。

\replength是划线/间隙循环的周期(长度)。

\rulewidth是填充规则的厚度。

在下面的 MWE 中,我将定制的\drulefill与标准的进行了比较\hrulefill

\documentclass[10pt]{article}
\newlength\replength
\newcommand\ruleht{3pt}% ELEVATION OF RULE
\newcommand\repfrac{.66}% SOLID FRACTION OF DASH LINE [0->1] (USE 1 FOR SOLID)
\replength=.6em\relax% PERIOD OF DASHED RULE
\newcommand\rulewidth{1pt}% THICKNESS OF RULE
\newcommand\drulefill{\leavevmode\dashfill\hfil%
  \kern\dimexpr\repfrac\replength-\replength\relax}
\newcommand\dashfill[1][\repfrac]{\cleaders\hbox to \replength{%
  \smash{\rule[\ruleht]{\repfrac\replength}{\rulewidth}}}\hfill}
\begin{document}
X\drulefill\par
Z\drulefill dhf\drulefill sj\drulefill

\renewcommand\ruleht{-2pt}% ELEVATION OF RULE
\renewcommand\repfrac{1}% SOLID FRACTION OF DASH LINE [0->1] (USE 1 FOR SOLID)
\replength=1.5pt\relax% PERIOD OF DASHED RULE
\renewcommand\rulewidth{.4pt}% THICKNESS OF RULE

X\drulefill\par
Z\drulefill dhf\drulefill sj\drulefill

X\hrulefill\par
Z\hrulefill dhf\hrulefill sj\hrulefill
\end{document}

在此处输入图片描述

答案4

使用以下微小代码行以各种方式玩转脚线:(正确遵​​循两个步骤)

  1. 在页眉或顶部包含以下内容。(宏):

    \def\Vrulefill#1#2#3#4{
    \color{gray}% You can keep any color you like.
    \leavevmode%
    \hskip-.2in%
    \leaders%
    \vtop{\hsize=#1\vskip#2#3}%
    \hfill%
    \hsize #4%
    \hskip.1in%**
    }
    
  2. 当您想要插入脚注时,请包含以下任意代码:

    \Vrulefill{0.0025in}{0.1in}{\vline height .1em width 1pt }{3in}
    

描述:
每个括号将确定脚尺的属性。#1确定构成线条的点的密度,#2确定线条的垂直偏移,#3确定线条的高度或厚度,#4确定线条的长度。\Vrulefil是在顶部定义的宏。

\Vrulefill{0.05in}{0.1in}{@ }{3in}

描述:
如果#1减少并且#3@/等,那么就可以产生一些有趣的装饰规则。

相关内容