\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
> 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
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
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
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
\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
It is indeed in TeX�Live 2009.
> 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>