1

I am currently defining a list environment that, until now, worked just fine for my purposes. However, it turns out that when adding a string of (non-math) numbers that is too long, LaTex will fail to break into two different lines, thus generating a line that is too large (i.e., overfull warning). Here is the MWE:

\documentclass[a4paper]{article}

\begin{document}

\newdimen\colsep \colsep=1em
\def\topbox#1#2{\vtop{\parindent=0pt \hsize=\dimexpr#1\relax #2}}
\def\entryb#1#2#3#4{\par
   \vspace{5pt}\hbox{\topbox{1.75cm}{#1\raggedleft}\kern\colsep
         \topbox{\hsize-2\colsep-1.75cm}{{\bf#2}\hfill {\footnotesize#3}\endgraf#4}}
   \smallskip
}

  \entryb
    {[1]}
    {\normalfont{Author (XXXX)} \textit{Very fancy title}. \textbf{Not so fancy journal} \normalfont{(forthcoming), pp. ?--?. DOI: 10.19292020384080/03059.8374659022.20945896}}
    {}
    {}
    
\end{document}

Here is the output:

enter image description here

As you can see, the line containing the DOI is longer than it should.

Can anybody please help me find a way to tell LaTex to automatically break any string of numbers that is too long?

Thank you all very much for your help.

2
  • 1
    Excellent MWE, by the way.
    – Mico
    Commented Jun 25, 2022 at 20:31
  • Thank you! However, I do not want to take credit for what is not mine. So there goes the question from which I got this list environment: tex.stackexchange.com/questions/640465/…
    – EoDmnFOr3q
    Commented Jun 25, 2022 at 20:47

1 Answer 1

1

You could (a) load the seqsplit package and (b) encase the doi string in a \seqsplit wrapper.

enter image description here

\documentclass[a4paper]{article}
\newdimen\colsep \colsep=1em
\def\topbox#1#2{\vtop{\parindent=0pt \hsize=\dimexpr#1\relax #2}}
\def\entryb#1#2#3#4{\par
   \vspace{5pt}\hbox{\topbox{1.75cm}{#1\raggedleft}\kern\colsep
         \topbox{\hsize-2\colsep-1.75cm}{{\bf#2}\hfill {\footnotesize#3}\endgraf#4}}
   \smallskip}
   
% new:
\usepackage{seqsplit}

\begin{document}

\entryb{[1]}
    {\normalfont{Author (XXXX)} 
    \textit{Very fancy title}. 
    \textbf{Not so fancy journal} 
    {\normalfont (forthcoming), pp.\ ?--?. 
    DOI: \seqsplit{10.19292020384080/03059.8374659022.20945896}}}
    {}{}
    
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .