当长标识符出现在正文中时,最佳做法是什么Character.isJavaIdentifierStart
?我知道该path
软件包还处理其他活动字符。
有时我有本地定义
\def\+{\discretionary{}{}{}}
它引入了连字符点\+
但没有连字符,以避免混淆连字符是否属于标识符。
答案1
我不太确定是否有这种best
做法,但这里有两种方法。
第一种方法使用url
命令自动在某些点(例如点)处进行连字符连接。第二种方法使用自由选择(带或不带连字符)。无论你选择哪种方法,我都确信你需要给 TeX 一点帮助,也就是说你最终无法避免进行一些手动编辑。
在示例中,我给单词添加了颜色,并使用了 libertine 系列字体。
\documentclass{report}
\usepackage{geometry,xcolor,url}
\usepackage{libertine}
\geometry{paperwidth=130mm, paperheight=60mm,
textwidth=95mm, textheight=50mm}
\def\+{\discretionary{}{-}{}}
\def\textinline#1{{\usefont{T1}{fxb}{m}{n}\selectfont\textcolor{purple}{\url{#1}}}}
\def\ttextinline#1{{\usefont{T1}{fxb}{m}{n}\selectfont\textcolor{purple}{#1}}}
\begin{document}
Java programmers tend like to use very long variable names as compared to other
languages. A string such as \textinline{this.class.VariableName}
will get split rather than produce an overfull box?
Java programmers tend like to use very long variable names as compared to other
languages. A string such as \ttextinline{this.classVari\+ableName}
will get split rather than produce an overfull box?
\end{document}