groff
[Top][All Lists]

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: Sat, 11 Feb 2012 22:07:34 -0000 (GMT)

```On 11-Feb-2012 Tadziu Hoffmann wrote:
> (Of course there's lots of stuff that can be tweaked.
> For example, I left out the extra line in the "easy" case
> because I personally didn't like it.)
>
> .\"
> .\" ------------------------------------------------------------------------
> .de Z
> .sp 2
> .nr n 1
> ..
> .\" ------------------------------------------------------------------------
> .\" mode register m: 1 = easy, 2 = medium, 3 = hard
> .\" ------------------------------------------------------------------------
> .\" You could also use .X in modes 2 & 3
> .de Q
> .if \\nm=1 .X \\\$@
> .if \\nm=2 .Y \\\$@
> .if \\nm=3 .Y \\\$@
> ..
> .\" ------------------------------------------------------------------------
> .\" Using blanks of variable length
> .de X
> .ds n \s'-2'\\nn\s'0'
> .if \\nm=1 .char _ \v'.2m'\h'.1m'\D'l .8m 0'\h'.1m'\v'-.2m'
> .if \\nm=2 .char _ \v'.2m'\D'l 1m 0'\v'-.2m'
> .if \\nm=3 .char _ \v'.2m'\D'l 1m 0'\v'-.2m'
> .tr a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_
> .nr w (\w'\\\$1'-\w'\\*n')/2
> \Z'\\\$1'\c
> .ds x \\\$1
> .substring x 0 0
> .if \\nm=1 \Z'\o'_\\*x''\c
> .if \\nm=2 \Z'\o'_\\*x''\c
> \h'\\nwu'\v'1m'\\*n\v'-1m'\h'\\nwu'\\\$2
> .nr n +1
> ..
> .\" ------------------------------------------------------------------------
> .\" Using blanks of fixed length
> .de Y
> .if \\nm=1 .tm Please use .X instead of .Y in "easy" mode
> .ds W \v'.2m'\D'l 3.5c 0'\v'-.2m'
> .ds n \s'-2'\\nn\s'0'
> .nr w (\w'\\*W'-\w'\\*n')/2
> .ds x \\\$1
> .substring x 0 0
> .if \\nm=1 \Z'\|\\*x'\c
> .if \\nm=2 \Z'\|\\*x'\c
> \Z'\\*W'\c
> \h'\\nwu'\v'1m'\\*n\v'-1m'\h'\\nwu'\\\$2
> .nr n +1
> ..
> .\" ------------------------------------------------------------------------
> .sp 3c
> .ps 12
> .vs 14
> .\" ------------------------------------------------------------------------
> .nr m 1
> .Z
> I am
> .Q honored
> to be with you today at your
> .Q commencement .
> .nr m 2
> .Z
> I am
> .Q honored
> to be with you today at your
> .Q commencement .
> .nr m 3
> .Z
> I am
> .Q honored
> to be with you today at your
> .Q commencement .