打破打字机风格的去标记化文本

打破打字机风格的去标记化文本

目标是让 snake_cased 元素以打字机样式正确断开。我使用\detokenize而不是 ,\_因为否则 snake_casing 看起来不对,即像这样:

\textt{已标准化}

而不是像这样

\texttt{\detokenize{已标准化}}

但 LaTeX 不会破坏它们。这是一个基本示例:

\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}

删除该draft选项\sloppy会使问题更加清晰。

答案1

_我宁愿允许在最容易使用的包之后中断,而不是允许使用连字符url。还要注意,你的定义在定义中的行尾添加了大量虚假的空白。

在此处输入图片描述

\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}

相关内容