[comp.text] Monospace in TeX/LaTeX

ben@tasis.utas.oz.au@munnari.oz (Ben Lian) (07/11/89)

I am trying to typeset some program fragments in typewriter style. At
the moment I do this by defining a new (LaTeX) tabbing environment and
then doing things like

\begin{program}
\>{\tt TYPE} \\
\>\>{\tt T1 = PRODUCT} \\
\>\>\>{\tt f1 : word} \\
\>\>\>{\tt f2 : word} \\
\>\>{\tt END}
\>{\tt END}
\end{program}

(1)  There must be an easier way of doing this, and I'd appreciate it if
     you could let me in on the secret;

(2)  The single space between each colon and the following 'word' gets
     expanded to what looks like something between 1.5 and 2 spaces.
     Why is this happening? And what can be done about it? (This is also
     happening with 'c ! e' and 'c ? v'.

I must have program fragments in typewriter style in order to distinguish
them from other examples which may be mistaken for program fragments.

Ben Lian



-----------------------------------------------------------------------
Benjamin Y H Lian             ACSnet: ben@tasis.utas.oz
Dept. of EE & CS              ARPA  : ben%tasis.utas.oz.au@uunet.uu.net
University of Tasmania        BITnet: munnari!tasis.utas.oz!ben@
GPO Box 252C                          uunet.uu.net
Hobart, Tasmania 7001         UUCP  : {enea,hplabs,mcvax,uunet,ukc}!
A U S T R A L I A                     munnari!tasis.utas.oz!ben

Tel:  +61-02-202380           Fax:  +61-02-202713
-----------------------------------------------------------------------

"Fortunately the computer virus did no harm to our records.  It was
immediately devoured by all the bugs in our programming."

-- Cartoon, CW Australia

debra@alice.UUCP (Paul De Bra) (07/12/89)

In article <955@diemen.cc.utas.oz> ben@tasis.utas.oz.au@munnari.oz (Ben Lian) writes:
?I am trying to typeset some program fragments in typewriter style. At
?the moment I do this by defining a new (LaTeX) tabbing environment and
?then doing things like
?
?\begin{program}
?\>{\tt TYPE} \\
?\>\>{\tt T1 = PRODUCT} \\
?\>\>\>{\tt f1 : word} \\
?\>\>\>{\tt f2 : word} \\
?\>\>{\tt END}
?\>{\tt END}
?\end{program}
?...

I use the "verbatim" environment.
Assuming you know about that, what is it that you want to do that
"verbatim" doesn't?

Paul.

-- 
------------------------------------------------------
|debra@research.att.com   | uunet!research!debra     |
------------------------------------------------------

jwright@atanasoff.cs.iastate.edu (Jim Wright) (07/12/89)

In article <9600@alice.UUCP> debra@alice.UUCP () writes:
| In article <955@diemen.cc.utas.oz> ben@tasis.utas.oz.au@munnari.oz (Ben Lian) writes:
| ?I am trying to typeset some program fragments in typewriter style.
| 
| I use the "verbatim" environment.

Other possibilities are the "alltt" environment style option and using
the "tgrind" program.

-- 
Jim Wright
jwright@atanasoff.cs.iastate.edu

d87-jse@nada.kth.se (Joakim Sernbrant) (07/12/89)

In article <955@diemen.cc.utas.oz> ben@tasis.utas.oz.au@munnari.oz (Ben Lian) writes:
>I am trying to typeset some program fragments in typewriter style. At
>the moment I do this by defining a new (LaTeX) tabbing environment and
>then doing things like
>
>\begin{program}
>\>{\tt TYPE} \\
>\>\>{\tt T1 = PRODUCT} \\
>\>\>\>{\tt f1 : word} \\
>\>\>\>{\tt f2 : word} \\
>\>\>{\tt END}
>\>{\tt END}
>\end{program}
>
>(1)  There must be an easier way of doing this, and I'd appreciate it if
>     you could let me in on the secret;

Try this:
\begin{verbatim}
  TYPE
    T1 = PRODUCT
           f1 : word
           f2 : word
         END
  END
\end{verbatim}
The verbatim environment copies the text exactly as you enter it;
with spaces and all.

>(2)  The single space between each colon and the following 'word' gets
>     expanded to what looks like something between 1.5 and 2 spaces.
>     Why is this happening? And what can be done about it? (This is also
>     happening with 'c ! e' and 'c ? v'.

LaTeX handles a colon as a punctation mark, and therefore
adds some space after it. No space is added in the verbatim 
environment though.

-- 
--  Joakim Sernbrant, Royal Institute of Technology, Stockholm, Sweden
--  Internet:  d87-jse@nada.kth.se
--

dougcc@csv.viccol.edu.au (Douglas Miller) (07/12/89)

In article <955@diemen.cc.utas.oz>, ben@tasis.utas.oz.au@munnari.oz
 (Ben Lian) writes:
> I am trying to typeset some program fragments in typewriter style. At
> the moment I do this by defining a new (LaTeX) tabbing environment 

> (2)  The single space between each colon and the following 'word' gets
>      expanded to what looks like something between 1.5 and 2 spaces.
>      Why is this happening? And what can be done about it? (This is also
>      happening with 'c ! e' and 'c ? v'.

Sounds like end of sentence space is being inserted. \frenchspacing will fix
this, or better still...

> (1)  There must be an easier way of doing this, and I'd appreciate it if
>      you could let me in on the secret;

...use the verbatim environment.  This will enable you to insert program
fragments unmodified from the program source.

I like to use a modified version of verbatim that sets \tt in 10pt with
\baselineskip=10pt (the main text is standard 12pt roman).

bts@sas.UUCP (Brian T. Schellenberger) (07/13/89)

Use \frenchspacing to avoid the extra space after `:' (and `.', `!', & `?').

Why not use \verbatim?  Otherwise, why not define a "ttprogram" environment
which does \frenchspacing and \tt after a \begin{program}?
-- 
-- Brian, the Man from Babble-on.		...!mcnc!rti!sas!bts
--
"Every jumbled pile of person has a thinking part that wonders what the part
that isn't thinking isn't thinking of" -- THEY MIGHT BE GIANTS

ben@tasis.utas.oz.au@munnari.oz (Ben Lian) (07/15/89)

In article <1192@atanasoff.cs.iastate.edu> jwright@atanasoff.cs.iastate.edu.UUCP (Jim Wright) writes:
>In article <9600@alice.UUCP> debra@alice.UUCP () writes:
>| In article <955@diemen.cc.utas.oz> ben@tasis.utas.oz.au@munnari.oz (Ben Lian) writes:
>| ?I am trying to typeset some program fragments in typewriter style.
>| 
>| I use the "verbatim" environment.
>
>Other possibilities are the "alltt" environment style option and using
>the "tgrind" program.

Actually, I do know about the verbatim environment (don't have tgrind though).
The reason for my original posting was that I did not (and still do not) know
how to change margins within an environment. Ideally, I would like to use
verbatim, but with the left margin increased by \mathindent (2.5em I think).
No change to right margin.

And here's another question: How can I draw a box around a figure? Tried
\framebox but it keeps keeling over with a message about not being in outer
par mode, or something like that.

Ben Lian




-----------------------------------------------------------------------
Benjamin Y H Lian             ACSnet: ben@tasis.utas.oz
Dept. of EE & CS              ARPA  : ben%tasis.utas.oz.au@uunet.uu.net
University of Tasmania        BITnet: munnari!tasis.utas.oz!ben@
GPO Box 252C                          uunet.uu.net
Hobart, Tasmania 7001         UUCP  : {enea,hplabs,mcvax,uunet,ukc}!
A U S T R A L I A                     munnari!tasis.utas.oz!ben

Tel:  +61-02-202380           Fax:  +61-02-202713
-----------------------------------------------------------------------

"Fortunately the computer virus did no harm to our records.  It was
immediately devoured by all the bugs in our programming."

-- Cartoon, CW Australia

dougcc@csv.viccol.edu.au (Douglas Miller) (07/20/89)

In article <957@diemen.cc.utas.oz>, ben@tasis.utas.oz.au@munnari.oz
(Ben Lian) writes:
> Actually, I do know about the verbatim environment (don't have tgrind though).
> The reason for my original posting was that I did not (and still do not) know
> how to change margins within an environment. Ideally, I would like to use
> verbatim, but with the left margin increased by \mathindent (2.5em I think).
> No change to right margin.

Verbatim is defined as follows

   \def\verbatim{\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}

Changing this to:

   \def\verbatim{\advance\@totalleftmargin by \mathindent
      \@verbatim \frenchspacing\@vobeyspaces \@xverbatim}

in a style option file might do the trick.

> And here's another question: How can I draw a box around a figure? Tried
> \framebox but it keeps keeling over with a message about not being in outer
> par mode, or something like that.

   I would think you need to put your figure into a box before you frame it.