0

The goal is to have snake_cased elements typewriter-styled breaking properly. I am using \detokenize rather than simply \_ because otherwise the snake_casing looks wrong, namely like this:

\textt{is_normalized}

rather than like this

\texttt{\detokenize{is_normalized}}

But LaTeX will not break them. Here is a basic example:

\documentclass[draft,11pt]{article}
\sloppy


\begin{document}


\newcommand{\isnormalized}[1]{
\texttt{\detokenize{is_normalized}}(\ensuremath{#1})
}

\newcommand{\atomincons}[2]{
\texttt{\detokenize{is_atomically_inconsistent}}(\ensuremath{#1,#2})
}

\newcommand{\containsnodiamond}[1]{
\texttt{\detokenize{contains_no_diamond}}(\ensuremath{#1})
}

\newcommand{\containsonlyliterals}[1]{
\texttt{\detokenize{contains_only_literals}}(\ensuremath{#1})
}

\newcommand{\prop}{\textsc{prop}}


The procedures do as their names say. Specifically, \atomincons{\Delta}{\prop} returns \textbf{1}
if there exist both $p$ and $\neg p$ in $\Delta$ for some propositional letter
$p\in\prop$ and returns \textbf{0} otherwise. \containsonlyliterals{\Delta} returns \textbf{1} if $\Delta$ contains only atomic
literals and \textbf{0} otherwise. \containsnodiamond{\Delta} returns
\textbf{1} if there is no formula of the form $\langle a\rangle \varphi'$ in
$\Delta$ and \textbf{0} otherwise. Note that \isnormalized{\Delta},
\containsonlyliterals{\Delta} and \containsnodiamond{\Delta} runs in time linear
in the size of the set $\Delta$ while \atomincons{\Delta}{\prop} takes time at
most quadratic in the size of $\Delta$.


\end{document}

Removing the draft option and \sloppy makes the problem clearer.

sunless
  • 319
  • 1
    tokenization isn't involved it is just the font setup see this possible duplicate https://tex.stackexchange.com/questions/44361/how-to-automatically-hyphenate-within-texttt – David Carlisle Jan 15 '16 at 13:01
  • You are right. Forgot to test that. I should probably delete the question? – sunless Jan 15 '16 at 13:04
  • But with detokenize I cannot use an hypen character. Is the linked solution working anyway? – sunless Jan 15 '16 at 13:11
  • what do you mean by can't use the hyphen character ( \- obviously doesn't work but it doesn't affect automatic hyphenation) Probably I would leave breaking disabled between letters and just allow it after _ (and don't add a hyphen at all – David Carlisle Jan 15 '16 at 13:16
  • But if I do: \DeclareTextFontCommand{\mytexttt}{\ttfamily\hyphenchar\font=-1\relax}, \newcommand{\atomincons}[2]{ \mytexttt{\detokenize{is_atomically_inconsistent}}(\ensuremath{#1,#2}) }, then there is still no automatic hyphenation. – sunless Jan 15 '16 at 13:19
  • you'd have to make _ a letter as well (\lccode \_=`_` would do, but see alternative approach I just posted as an answer) – David Carlisle Jan 15 '16 at 13:23

1 Answers1

1

Rather than allow hyphenation I would just allow things to break after _ most easily using url package. Also beware your definitions added a lot of spurious white space from ends of lines in the definitions.

enter image description here

\documentclass[draft,11pt]{article}

\usepackage{url}


\begin{document}


\newcommand{\isnormalized}[1]{%
\path{is_normalized}($#1$)%
}

\newcommand{\atomincons}[2]{%
\path{is_atomically_inconsistent}($#1,#2$)%
}

\newcommand{\containsnodiamond}[1]{%
\path{contains_no_diamond}($#1$)%
}

\newcommand{\containsonlyliterals}[1]{%
\path{contains_only_literals}($#1$)%
}

\newcommand{\prop}{\textsc{prop}}


The procedures do as their names say. Specifically, \atomincons{\Delta}{\prop} returns \textbf{1}
if there exist both $p$ and $\neg p$ in $\Delta$ for some propositional letter
$p\in\prop$ and returns \textbf{0} otherwise. \containsonlyliterals{\Delta} returns \textbf{1} if $\Delta$ contains only atomic
literals and \textbf{0} otherwise. \containsnodiamond{\Delta} returns
\textbf{1} if there is no formula of the form $\langle a\rangle \varphi'$ in
$\Delta$ and \textbf{0} otherwise. Note that \isnormalized{\Delta},
\containsonlyliterals{\Delta} and \containsnodiamond{\Delta} runs in time linear
in the size of the set $\Delta$ while \atomincons{\Delta}{\prop} takes time at
most quadratic in the size of $\Delta$.


\end{document}
David Carlisle
  • 757,742