テレタイプフォントの適切な改行

テレタイプフォントの適切な改行

私の参考文献には、技術レポートのレポート番号をテレタイプ フォントで含めたいと考えています。これらのレポート番号は通常、 のようにハイフンでつながれた文字と数字のブロックで構成されますINSTITUTE-YEAR-MM-NUMBER。レポート番号は、ハイフンの後に改行しても問題ありません。

これまで、\nolinkurlあまり考えずに使用してきましたが、良い結果が得られています。今度は、スペースで残りのブロックから区切られた 1 つのブロックを持つレポート番号を含める必要があります。このスペースは によって抑制されます\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(プリアンブル内) をリセットすることもできます。

関連情報