# Word wrapping for short strings in parentheses

I have a markdown file that I process with pandoc. I have the following text in the .md file:

**Note:** The entire text above would be entered on a single command line
without the backslash (\).


Pandoc generates the following LaTeX code:

\textbf{Note:} The entire text above would be entered on a single
command line without the backslash (\texttt{\textbackslash{}}).


The output that is generated using pdflatex causes the to cause the open parenthesis ( to be on line one and the remaining \). to be on the next line.

I have redefined \texttt with the following:

\let\OldTexttt\texttt
\renewcommand{\texttt}[1][%
\hyphenpenalty=10000
\exhyphenpenalty=10000
\setlength{\emergencystretch}{6em}
\sethlcolor{codegray}%
{\ttfamily\hl{#1}}%
}


So, my question is, how can I prevent one letter be on one line and the rest of the "word" to be on the next? Basically, I want to not have word wrapping after a single character.

• There shouldn't be a break point behind the (, unless your document ist doing something curious. Show a complete minimal example that demonstrates the problem. – Ulrike Fischer Dec 21 '18 at 16:26
• are you sure there is no space after the ( ? Please show an example code. – David Carlisle Dec 21 '18 at 16:35
• Postive. That was the first thing I looked for. The above is exactly as it is in the file. – JonBelanger Dec 21 '18 at 16:48
• then please fix your example so that people can see the issue, as with default settings there would be no break after ( so you are asking about code you have not shown, which makes it hard to answer. – David Carlisle Dec 21 '18 at 17:28

You are inserting a space before the texttt with your redefinition. Hide it with a comment sign:

\documentclass[12pt, a4paper]{report}
\let\OldTexttt\texttt
\usepackage{soul}

\renewcommand{\texttt}[1]{%
\hyphenpenalty=10000
\exhyphenpenalty=10000
\setlength{\emergencystretch}{6em}%< hide this space
\sethlcolor{codegray}%
{\ttfamily\hl{#1}}%
}

\begin{document}
\textbf{Note:} The entire text above would be entered on a single
command line without the backslash (\texttt{\textbackslash{}}).

\end{document}


Be aware that your penalty settings are not grouped and so will affect following text.

• This is exactly what I was looking for. I new I missed something subtle. I also put a \begingroup and \endgroup around the start and end of this macro. – JonBelanger Dec 21 '18 at 22:19