[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Using variables from register within fractions or equations
From: |
Ted Harding |
Subject: |
Re: [Groff] Using variables from register within fractions or equations |
Date: |
Fri, 10 Feb 2012 10:14:07 -0000 (GMT) |
On 10-Feb-2012 maouinin wrote:
> What would be the best way to use a regularly incremented
> variable within fractions?
>
> I teach ESL and I hope to typeset cloze tests where selected
> individual words are replaced by a blank space (a short line
> or underscore) which has the question number printed below it.
> I have done this in LaTeX by using fractions within the math
> environment paired with a counter as the denominator:
>
> \newcommand{\pq}{\hspace{1mm} \stepcounter{qnum}
> \begin{math}
> _\frac{\hspace{3cm}}{\theqnum}
> \end{math}
> and the following:
>
> I am honored to be with you today at your commencement...
>
> becomes:
> I am h_______ to be with you today at your c________ ...
> 1 2
>
> Is this possible with groff, using eqn perhaps? Is it possible
> to use variables from number registers within equations or
> fractions?
> --
For the particular effect which you describe, it is not necessary
to use fractions and eqn. You can do it perfectly well using
basic troff primitives. The following produces the above result:
.nr subno 0 1
.ds qline \v'0.25m'\D'l 5m 0'\v'1.00m'\\n+[subno]\v'-1.25m'
.LP
I am h\*[qline] to be with you today at your c\*[qline]...
The ".nr subno 0 1" defines an auto-incrementing number register
\n[subno] whose initial value is 0 and which increments by 1 when
it is called using "\n+[subno]" (when called using "\n[subno]" it
is not incremented)
The ".ds qline etc" defines a string \*[qline] whose effect is
a) To move down by 0.25m
b) To draw a line at that level horizontally 5m, vertically 0
c) From the endpoint of that line, move down 1m and then
print the incremented value of \n[subno]
d) Move back up 1.25m (i.e. to the original level).
The various paramaters in \*[qline] can be varied according
to precisely how you would like the result to appear.
Regarding your final query, it is perfectly possible to use
variables from number (or other) registers within mathematical
expressions processed by eqn. The simplest method is simply
to place them within quotes, so that they will be treated as
text by eqn. For example:
.EQ
X = "\n[subno]" over "\n+[subno]"
.EN
but, as I said, that sort of thing is not needed for your
application as described.
Hoping this helps,
Ted.
-------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 10-Feb-2012 Time: 10:14:03
This message was sent by XFMail
-------------------------------------------------
- [Groff] Using variables from register within fractions or equations, maouinin, 2012/02/10
- Re: [Groff] Using variables from register within fractions or equations,
Ted Harding <=
- Re: [Groff] Using variables from register within fractions or equations, maouinin, 2012/02/10
- Re: [Groff] Using variables from register within fractions or equations, Ralph Corderoy, 2012/02/11
- Re: [Groff] Using variables from register within fractions or equations, maouinin, 2012/02/11
- Re: [Groff] Using variables from register within fractions or equations, Tadziu Hoffmann, 2012/02/11
- Re: [Groff] Using variables from register within fractions or equations, Ted Harding, 2012/02/11
- Re: [Groff] Using variables from register within fractions or equations, maouinin, 2012/02/17
- Re: [Groff] Using variables from register within fractions or equations, Ralph Corderoy, 2012/02/17
- Re: [Groff] Using variables from register within fractions or equations, Holger Herrlich, 2012/02/18
- Re: [Groff] Using variables from register within fractions or equations, Tadziu Hoffmann, 2012/02/19