I would like to avoid overfull \hbox
es as a result of inline code, inserted with \textt{foo}
or \ttfamily
, e.g. in this MWE:
% compile with xelatex
\documentclass{article}
\usepackage[textwidth=4cm, showframe]{geometry}% to force hyphenation
\usepackage{polyglossia}
\setdefaultlanguage[variant=usmax]{english}
\usepackage{fontspec}
\setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}
\setlength{\overfullrule}{1mm}
\begin{document}
{\ttfamily Bla \textbackslash newcommand\{\textbackslash foo\}\{bar\}
\textbackslash setmonofont[Scale=MatchLowercase]\{DejaVu Sans Mono\}
For regular words, it works supercalifragilisticexpialidociously (or more like kind of ok),
but real code is tricky.}
\end{document}
I'd like to have hyphenation points (manual instruction is ok) between Match
and Lowercase
, and between {\foo}
and {bar}
. However, I don't ever want a hyphen to appear at hyphenation points (in typewriter text).
I've tried \-
, which doesn't work (babelshorthands
is not available for english
). I also know about the fontspec
option HyphenChar
, but I don't know how to tell it "no hyphenation character, but hyphentation" (space / 32
is not an option because it appears in the OCR layer of the pdf; None
would disable hyphenation altogether). I guess these might both be traces of the solution, but I can't figure out how to make use of them.
polyglossia
) with LuaLaTeX results in surprisingly different output, especially theMatchLowercase
part: i.stack.imgur.com/IGOHK.png (MiKTeX 2.9). Is that just a difference that's to be expected, or a bug on the side of LuaTeX/XeTeX/fontspec
? I.e. would this be of interest to any of the development teams?