
Na minha bibliografia, quero incluir números de relatórios técnicos em fonte teletipo. Esses números de relatório normalmente consistem em vários blocos de letras e números conectados por hífens, como INSTITUTE-YEAR-MM-NUMBER
. Não há problema em que os números dos relatórios tenham uma quebra de linha após qualquer um dos hífens.
Até agora, tenho usado \nolinkurl
sem pensar muito e dá bons resultados. Agora, preciso incluir números de relatórios que tenham um bloco separado do resto por um espaço. Este espaço é suprimido por \nolinkurl
.Nesta questãopara o mesmo problema, a resposta aceita é usar \texttt
em vez disso. No entanto, com \texttt
, as quebras automáticas de linha não funcionam.
Exemplo 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}
Como posso ter números de relatórios com hífens e espaços em fonte teletipo com quebras de linha automáticas?
Responder1
Use \path
, com uma modificação para expandir o conteúdo.
\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}
Responder2
Você poderia usar o pacote 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}
Ou você pode redefinir o hífen \ttfamily \hyphenchar\font=45
(no preâmbulo).