電傳打字機字體中的正確換行符

電傳打字機字體中的正確換行符

在我的參考書目中,我想以電傳打字機字體包含技術報告的報告編號。這些報告編號通常由用連字號連接的幾塊字母和數字組成,例如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

您可以使用連字符包:

\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(在序言中)。

相關內容