Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Customize \ttfamily for justification

273 views
Skip to first unread message

Martin Reinders

unread,
Jan 20, 2010, 12:16:57 PM1/20/10
to
Hi,
combining the code from
http://texblog.net/latex-archive/plaintex/full-justification-with-typewriter-font/
and
http://projekte.dante.de/DanteFAQ/Silbentrennung
I have redefined \ttfamily to allow hyphenation and text
justification:

\newcommand{\origttfamily}{}
\let\origttfamily=\ttfamily
\renewcommand{\ttfamily}{\origttfamily
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
\hyphenchar\font=`\-
}

This works fine. My problem is that this modification applies also to
the "verbatim" environment. But I want the flexible space only for
\texttt{ .... }. In the "verbatim" environment, all spaces should have
the fixed width.

Thank you for any help!
Martin

Herbert Voss

unread,
Jan 20, 2010, 12:29:22 PM1/20/10
to
Am 20.01.2010 18:16, schrieb Martin Reinders:

> combining the code from
> http://texblog.net/latex-archive/plaintex/full-justification-with-typewriter-font/
> and
> http://projekte.dante.de/DanteFAQ/Silbentrennung
> I have redefined \ttfamily to allow hyphenation and text
> justification:
>
> \newcommand{\origttfamily}{}
> \let\origttfamily=\ttfamily
> \renewcommand{\ttfamily}{\origttfamily
> \fontdimen2\font=0.4em% interword space
> \fontdimen3\font=0.2em% interword stretch
> \fontdimen4\font=0.1em% interword shrink
> \fontdimen7\font=0.1em% extra space
> \hyphenchar\font=`\-
> }

no need for this definitions with lmvtt ...

\documentclass[ngerman,a4paper]{article}
\usepackage[T1]{fontenc}
\renewcommand*\ttdefault{lmvtt}
\usepackage{babel,blindtext}
\makeatletter
\def\verbatim@font{\fontfamily{lmtt}\selectfont}
\makeatother
\begin{document}
\ttfamily
\blindtext

\begin{verbatim}
foo bar baz und so weiter
\end{verbatim}
\end{document}

Herbert

Franck Pastor

unread,
Jan 20, 2010, 1:01:12 PM1/20/10
to

Note that there exists now an useful option for the lmodern package, to
obtain the lmvtt fonts easily: variablett

\usepackage[variablett]{lmodern}

Another useful option: lighttt, for using the light teletype family.

Their definition is very well hidden in this file:
http://www.ctan.org/tex-archive/fonts/ps-type1/lm/doc/fonts/lm/lm-hist.txt


Martin Reinders

unread,
Jan 21, 2010, 11:46:17 AM1/21/10
to
On 20 Jan., 18:29, Herbert Voss <Herbert.V...@FU-Berlin.de> wrote:
>
> no need for this definitions with lmvtt ...
>
Thank you for this information, I did not know the Latin Modern fonts.
I tried your solution, and it works.

But the lmtt font and in particular the lmvtt font look (in my
opinion) too different from Courier (or TeX Gyre Cursor) used before.
And lmvtt is a real proportional font (with all character width
different), I wanted only the interword space to be flexible for
better justification and line breaking.

After much trying I found that the original method (redefining
\ttfamily) works if the interword space (\fontdimen2) is not
redefined. In the verbatim environment, all characters including space
still have the same width, probably because TeX does no justification
there.

Thanks to all who replied to my question.

Martin

Peter Flynn

unread,
Jan 23, 2010, 1:18:47 PM1/23/10
to
Franck Pastor wrote:
[...]

> Note that there exists now an useful option for the lmodern package, to
> obtain the lmvtt fonts easily: variablett
>
> \usepackage[variablett]{lmodern}
>
> Another useful option: lighttt, for using the light teletype family.

What version is required for these?

> l.3 \usepackage
> {multicol}
> The option `lighttt' was not declared in package `lmodern', perhaps you
> misspelled its name. Try typing <return> to proceed.

I'm using

> (/usr/share/texmf/tex/latex/lm/lmodern.sty
> Package: lmodern 2007/01/14 v1.3 Latin Modern Fonts

///Peter

Robin Fairbairns

unread,
Jan 23, 2010, 3:21:54 PM1/23/10
to

\ProvidesPackage{lmodern}[2009/10/30 v1.6 Latin Modern Fonts]

has both options. (i presume it's in tl2009, but i've no easy way of
telling, sitting on this old crock of a workstation at home.)
--
Robin Fairbairns, Cambridge

Franck Pastor

unread,
Jan 23, 2010, 3:52:24 PM1/23/10
to

It is indeed in TeX�Live 2009.


Heiko Oberdiek

unread,
Jan 23, 2010, 5:38:54 PM1/23/10
to
rf...@cl.cam.ac.uk (Robin Fairbairns) wrote:

> Peter Flynn <peter...@m.silmaril.ie> writes:
> >Franck Pastor wrote:
> >[...]
> >> Note that there exists now an useful option for the lmodern package, to
> >> obtain the lmvtt fonts easily: variablett
> >>
> >> \usepackage[variablett]{lmodern}
> >>
> >> Another useful option: lighttt, for using the light teletype family.
> >
> >What version is required for these?

> \ProvidesPackage{lmodern}[2009/10/30 v1.6 Latin Modern Fonts]


>
> has both options. (i presume it's in tl2009, but i've no easy way of
> telling, sitting on this old crock of a workstation at home.)

TDS:doc/fonts/lm/lm-hist.txt tells:

| Ver. 2.003, 16.09.2009:
| [...]
| * LaTeX *.sty and *.fd files reworked, options `nomath' (prevents loading
| LM math fonts), `lighttt' and `variablett' added; sample usage:
| \usepackage{lmodern}
| \usepackage[nomath]{lmodern}
| \usepackage[variablett]{lmodern}
| \usepackage[lighttt,variablett]{lmodern}
| very many thanks to Marcin Woli\'nski

The current version of the updated TL 2009 is:

\ProvidesPackage{lmodern}[2009/10/30 v1.6 Latin Modern Fonts]

Yours sincerely
Heiko <ober...@uni-freiburg.de>

0 new messages