下面两个例子取自Douglas Crockford的著名著作第69(或66)页和第76页。我不知道如何在TeX中输入它们。
示例 1:
Those are the factors of the regular expression parse\_url.\footnote{
When you press them all together again, it is visually quite confusing: \\
/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/
}
示例 2:
(?:!|"|#|\$|%|&|'|\(|\)|\*|\+|,|-|\.|\/|:|;|<|=|>|@|\[|\\|]|\^|_|` |\{|\||\}|~)
我已经尝试过\texttt{ }
和\verb
,但似乎不起作用。
答案1
您可以使用\verb
,但您必须找到未出现在正则表达式中的分隔符。例如,您可以使用1
作为分隔符:\verb1...1
对于脚注中的逐字文本,您可以使用例如fancyvrb
包。
\documentclass{article}
\usepackage{fancyvrb}
\VerbatimFootnotes
\begin{document}
Those are the factors of the regular expression parse\_url.\footnote{
When you press them all together again, it is visually quite confusing: \\
\verb1/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/1
}
\verb1(?:!|"|#|\$|%|&|'|\(|\)|\*|\+|,|-|\.|\/|:|;|<|=|>|@|\[|\\|]|\^|_|` |\{|\||\}|˜)1
\end{document}