1

有人可以向我解释为什么在.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 
4

2 回答 2

2

当您编写以下行时:

.nr a4_margin_horizontal 1c

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

以后写的时候:

.po \n[a4_margin_horizontal]

没有刻度指示器;因此解释器依赖于根据行布局(手册页)的默认比例指示器。m

如果要使其工作,请在请求u后添加指示符:\n

.po \n[a4_margin_horizontal]u
于 2018-11-03T10:34:33.713 回答
1

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

从在线手册:

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

我的度量单位1c(1 厘米)被转换为 28346 个“基本单位”(每英寸 72,000 个),并且.po请求应该是默认的度量单位。

于 2018-11-03T10:34:08.500 回答