Difference between revisions of "Bold typewriter"

From Wiki
Jump to navigation Jump to search
m (category and texcode added)
(Clarified and expanded.)
Line 1: Line 1:
< [[From LaTeX to ConTeXt]]
+
< [[From LaTeX to ConTeXt]] >
 +
 
 +
== LaTeX ==
 +
 
 +
In LaTeX, one can declare <code>cmttb10</code> as a boldface version of <code>cmtt</code> and then use i with the standard <code>\texttt</code> and <code>\textbf</code> commands.
  
LaTeX:
 
 
<texcode>
 
<texcode>
 
\documentclass{article}
 
\documentclass{article}
Line 11: Line 14:
 
</texcode>
 
</texcode>
  
ConTeXt:
+
== ConTeXt ==
Put this in <code>/usr/share/texmf/tex/context/third/type-loc.tex</code> to define the bold typewriter fonts:
+
 
 +
The exact same thing can be done in ConTeXt, although the syntax is slightly more verbose.
 +
 
 +
<texcode>
 +
\definebodyfont [12pt] [tt] [bf=cmttb10 at 12pt]
 +
\definebodyfont [11pt] [tt] [bf=cmttb10 at 11pt]
 +
\definebodyfont [10pt] [tt] [bf=cmttb10]
 +
\definebodyfont [9pt] [tt] [bf=cmttb10 at 9pt]
 +
\definebodyfont [8pt] [tt] [bf=cmttb10 at 8pt]
 +
 
 +
\starttext
 +
{\tt Normal and \bf bold Typewriter.}
 +
\stoptext
 +
</texcode>
 +
 
 +
However, instead of requiring that this be defined in each document, ConTeXt also provides the possibility of including it automatically as part of the default font setups.  This can be done by putting the following typescript definitions in <code>/usr/share/texmf/tex/context/third/type-loc.tex</code>.  The version shown here also includes a switch between <code>cmttb10</code> and the newer (and bolder) <code>cmbtt</code> family.
 +
 
 
<texcode>
 
<texcode>
 
\newif\ifVeryBoldTT % turn this on, if it's not bold enough:
 
\newif\ifVeryBoldTT % turn this on, if it's not bold enough:
Line 33: Line 52:
 
</texcode>
 
</texcode>
  
<code>cmbtt[8,9,10]</code> is the more recent family of fonts and bolder than the older <code>cmttb10</code> font.
+
Then, the fonts can be accessed without any additional setup in the documents, as in this example:
 
 
Then, the fonts can be accessed as in this example:
 
 
<texcode>
 
<texcode>
 
\starttext
 
\starttext

Revision as of 01:23, 4 September 2005

< From LaTeX to ConTeXt >

LaTeX

In LaTeX, one can declare cmttb10 as a boldface version of cmtt and then use i with the standard \texttt and \textbf commands.

\documentclass{article}
\DeclareFontShape{OT1}{cmtt}{bx}{n}{
  <5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
\begin{document}
\texttt{Normal and \textbf{bold Typewriter.}}
\end{document}

ConTeXt

The exact same thing can be done in ConTeXt, although the syntax is slightly more verbose.

\definebodyfont [12pt] [tt] [bf=cmttb10 at 12pt]
\definebodyfont [11pt] [tt] [bf=cmttb10 at 11pt]
\definebodyfont [10pt] [tt] [bf=cmttb10]
\definebodyfont [9pt] [tt] [bf=cmttb10 at 9pt]
\definebodyfont [8pt] [tt] [bf=cmttb10 at 8pt]

\starttext
{\tt Normal and \bf bold Typewriter.}
\stoptext

However, instead of requiring that this be defined in each document, ConTeXt also provides the possibility of including it automatically as part of the default font setups. This can be done by putting the following typescript definitions in /usr/share/texmf/tex/context/third/type-loc.tex. The version shown here also includes a switch between cmttb10 and the newer (and bolder) cmbtt family.

\newif\ifVeryBoldTT % turn this on, if it's not bold enough:
%\VeryBoldTTtrue
\starttypescript [mono] [computer-modern] [size]
\ifVeryBoldTT
  \definebodyfont [12pt] [tt] [bf=cmbtt10 at 12pt]
  \definebodyfont [11pt] [tt] [bf=cmbtt10 at 11pt]
  \definebodyfont [10pt] [tt] [bf=cmbtt10]
  \definebodyfont [9pt] [tt] [bf=cmbtt9]
  \definebodyfont [8pt] [tt] [bf=cmbtt8]
\else
  \definebodyfont [12pt] [tt] [bf=cmttb10 at 12pt]
  \definebodyfont [11pt] [tt] [bf=cmttb10 at 11pt]
  \definebodyfont [10pt] [tt] [bf=cmttb10]
  \definebodyfont [9pt] [tt] [bf=cmttb10 at 9pt]
  \definebodyfont [8pt] [tt] [bf=cmttb10 at 8pt]
\fi
\stoptypescript

Then, the fonts can be accessed without any additional setup in the documents, as in this example:

\starttext
{\tt Normal and \bf bold Typewriter.}
\stoptext