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) <ted.hard...@wlandres.net> Date: 10-Feb-2012 Time: 10:14:03 This message was sent by XFMail -------------------------------------------------