
En mi bibliografía, quiero incluir números de informe de informes técnicos en fuente de teletipo. Estos números de informe suelen constar de varios bloques de letras y números conectados por guiones, como INSTITUTE-YEAR-MM-NUMBER
. Está bien que los números de informe tengan un salto de línea después de cualquiera de los guiones.
Hasta ahora lo he estado usando \nolinkurl
sin pensarlo mucho y da buenos resultados. Ahora, necesito incluir números de informe que tengan un bloque separado del resto por un espacio. Este espacio está suprimido por \nolinkurl
.en esta preguntaal mismo problema, la respuesta aceptada es usar \texttt
en su lugar. Sin embargo, con \texttt
, los saltos de línea automáticos no funcionan.
Ejemplo mínimo:
\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}
¿Cómo puedo tener números de informe con guiones y espacios en fuente de teletipo con saltos de línea automáticos?
Respuesta1
Utilice \path
, con una modificación para ampliar el contenido.
\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}
Respuesta2
Podrías usar el paquete 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}
O puede restablecer el guión \ttfamily \hyphenchar\font=45
(en el preámbulo).