Text FormattingTypewriter font and em dash

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
exploded_funk
Posts: 3
Joined: Sat Feb 25, 2012 3:46 pm

Typewriter font and em dash

Post by exploded_funk »

I'm writing a thesis in Lyx and I'm using the Courier font. I have many dashes like this in the text but in the PDF all I get is two small dashes like this --.

I wanted to know if there is a way to insert a long dash . I know that the mono spaced fonts are not designed for this but it would be a nice addition.

The preamble of my LyX document is as follows.

Code: Select all

\begin_document
\begin_header
\textclass memoir
\begin_preamble
\usepackage{blindtext}
\usepackage{everysel}
\renewcommand*\familydefault{\ttdefault}
\EverySelectfont{%
\fontdimen2\font=0.7em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
\hyphenchar\font=`\-% to allow hyphenation
}

…

\language french
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter courier
\font_default_family ttdefault
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
Last edited by localghost on Sun Nov 17, 2013 10:25 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Typewriter font and em dash

Post by kaiserkarl13 »

You can try using kerning to overlay multiple hyphens, which will mimic this:

Code: Select all

\documentclass{article}
\usepackage{times}
\newcommand*{\longndash}{-\kern-0.28em-\kern-0.28em-}
\newcommand*{\longmdash}{-\kern-0.20em-\kern-0.20em-\kern-0.20em-}
\begin{document}
\setlength{\parindent}{0pt}
This is a test-like test.\\
This is a test---a very long test.\\
\begin{tt}
This is a test-like test.\\
This is a test--a long test.\\
This is a test\longndash a long test.\\
This is a test---a very long test.\\
This is a test\longmdash a very long test.\\
\end{tt}
\end{document}
You might want to put an \mbox around the dashes in the command definitions to make sure there are no stray line breaks.
Post Reply