在我的参考书目中,我想以电传打字机字体包含技术报告的报告编号。这些报告编号通常由几个字母和数字块组成,这些字母和数字块由连字符连接,例如INSTITUTE-YEAR-MM-NUMBER
。报告编号可以在任何连字符后换行。
到目前为止,我一直\nolinkurl
没有多想就使用它,它提供了良好的效果。现在,我需要包含一个块与其他块之间用空格隔开的报告编号。这个空格被 抑制了\nolinkurl
。在这个问题中对于同一问题,可接受的答案是改用\texttt
。但是,使用 时\texttt
,自动换行不起作用。
最小示例:
\documentclass[12pt]{article}
\PassOptionsToPackage{hyphens}{url}
\usepackage[breaklinks]{hyperref}
\usepackage{showframe}
\newcommand{\thereport}{REPORT-19-12-001 SPECIAL}
\begin{document}
This is a long line and at the end of the line there should be \texttt{\thereport} referenced.
This is a long line and at the end of the line there should be \nolinkurl{\thereport} referenced.
\end{document}
如何在电传打字机字体中显示带有连字符和空格且带有自动换行符的报告编号?
答案1
使用\path
,并进行修改以扩充内容。
\documentclass[12pt]{article}
\PassOptionsToPackage{hyphens,obeyspaces}{url}
\usepackage{hyperref}
\usepackage{showframe}
\newcommand{\epath}[1]{\expandafter\path\expandafter{#1}}
\newcommand{\thereport}{REPORT-19-12-001 SPECIAL}
\begin{document}
This is a long line and at the end of the line there should be
\epath{\thereport} referenced.
\end{document}
答案2
您可以使用 hyphenat 包:
\documentclass[12pt]{article}
\PassOptionsToPackage{hyphens}{url}
\usepackage[breaklinks]{hyperref}
\usepackage{showframe}
\newcommand{\thereport}{REPORT-19-12-001 SPECIAL}
\usepackage[htt]{hyphenat}
\begin{document}
This is a long line and at the end of the line there should be \texttt{\thereport} referenced.
This is a long line and at the end of the line there should be \nolinkurl{\thereport} referenced.
\end{document}
或者您可以重置连字符\ttfamily \hyphenchar\font=45
(在序言中)。