【问题标题】:Can a number register be used in a groff request?可以在 groff 请求中使用数字寄存器吗?
【发布时间】:2019-04-07 09:35:28
【问题描述】:

有人可以向我解释为什么在.po(“页面偏移”)请求中嵌入文字值(例如,“1c”)有效,但引用数字寄存器却无效?

.\" Set the dimensions of an A4 page.
.nr a4_width 21c
.nr a4_height 29.7c
.nr a4_margin_horizontal 1c
.nr a4_margin_vertical 1c
.nr a4_content (\n[a4_width] - (\n[a4_margin_horizontal] * 2))
.
.\" Page-offset and line-length
.po \n[a4_margin_horizontal]
.ll \n[a4_content]
.\" Uncomment the below two lines and everything works.
.\" .po 1c
.\" .ll 19c
.
.\" Start the document.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
.sp 

【问题讨论】:

    标签: units-of-measurement groff


    【解决方案1】:

    当你写下下面这行时:

    .nr a4_margin_horizontal 1c
    

    字母c是一个刻度指示器;因此存储在寄存器中的实际数值约为 28346。

    以后写的时候:

    .po \n[a4_margin_horizontal]
    

    没有刻度指示器;因此,根据line layout(手册页),解释器依赖于m默认比例指示器

    如果你想让它工作,请在\n 请求之后添加u 指示符:

    .po \n[a4_margin_horizontal]u
    

    【讨论】:

      【解决方案2】:

      有趣的是,我如何将头撞到墙上整整一个小时,然后当我终于在 StackOverflow 上提出问题时,我想通了。

      来自在线手册:

      gtroff(与许多其他程序一样)需要数字参数来指定 各种测量。大多数数字参数9可能有一个测量单位 随附的。这些单位被指定为单个字符,立即 跟在数字或表达式后面。这些单位中的每一个都被理解为 gtroff,是其基本单位的倍数。所以,每当不同的 指定测量单位 gtroff 将其转换为其基本单位。这 由“u”表示的基本单位是与设备相关的测量值,即 很小,从 1/75 到 1/72000 英寸不等。这些值可能是 以小数形式给出;但是,分数基本单位总是四舍五入 为整数。

      1c(1 厘米)的度量值正在转换为 28346 个“基本单位”(每英寸 72,000),.po 请求应为默认度量单位。

      【讨论】:

        猜你喜欢
        • 2015-03-01
        • 2014-04-08
        • 1970-01-01
        • 1970-01-01
        • 2011-02-11
        • 2017-09-09
        • 1970-01-01
        • 2019-09-01
        • 1970-01-01
        相关资源
        最近更新 更多