0

I am using Gareth Walker's package convtran for typesetting conversation analysis examples.

That package makes use of the linenumbering mechanism from lineno to number lines in the examples. All fine. But now I ran into a problem because a journal cls file from a journal I'm submitting to also makes use of lineno for linenumbering (in my case the MDPI LaTeX class) and that obviously clashes with the way linenumbers are set up for the examples (see the image).

enter image description here

Here's an MWE (requires convtran):

\documentclass{report}    
\usepackage{convtran}
\usepackage{lipsum}

\begin{document}
\linenumbers
\lipsum[4]

\begin{convtran}
    \turn{A:} Hello 
    \turn{B:} Hello 
\end{convtran}

\lipsum[4]
\end{document}

Is there any way to modify the way in which convtran uses the linenumbering mechanism in such a way that it doesn't interfere with linenumbering done via the cls file?

EDIT:
Essentially, I'd like to have complete linenumbers in the margins but still be able to use convtran with the specific linenumbers for transcripts (each starting from 1 without interfering with the linenumbers in the margins). This is how what I'm hoping to achieve should look:

enter image description here

2 Answers 2

3
+50

A proof-of-concept attempt. The key is to redefine \makeLineNumber so that it typesets line numbers twice. Current redefinition is (very) fragile to how convtran and lineno is used and/or configured.

\documentclass{report}
\usepackage{convtran}
\usepackage{lipsum}
\usepackage{xpatch} % for \xpatchcmd

% restore \linenumbersep changed by convtran
\setlength{\linenumbersep}{10pt}
\newcounter{convtran@start}

\makeatletter

\xpatchcmd\convtran
  {\linenumbers*}
  {%
    \ifLineNumbers
      \convtran@setMakeLineNumber
    \else
      \linenumbers*
      \convtran@restoreMakeLineNumber
    \fi
  }
  {}{\PatchFailed}

% 
\newcommand\convtran@setMakeLineNumber{%
  \let\makeLineNumber@orig=\makeLineNumber
  \setcounter{convtran@start}{\value{linenumber}}%
  \renewcommand\makeLineNumber{%
    \begingroup
      \setlinenoplace{-0.75cm}%
      \c@linenumber=\numexpr\c@linenumber-\c@convtran@start+1\relax
      \hbox to 0pt{\makeLineNumber@orig}% line number for convtran
    \endgroup
    \makeLineNumber@orig % normal line number
  }%
}

\newcommand\convtran@restoreMakeLineNumber{%
  \setlinenoplace{-0.75cm}%
}
\makeatother

\begin{document}

\newcommand\test{%
  \lipsum[4][1-4]
  
  \begin{convtran}
    \turn{A:} Hello 
    \turn{B:} Hello
  \end{convtran}
  
  \lipsum[4][1-4]
  \rule{\textwidth}{.4pt}\bigskip
}

\linenumbers
\test

\nolinenumbers
\test

\linenumbers[20]
\test

\end{document}

enter image description here

4
  • This looks very promising – but there's still one issue: when I outcomment \linenumbers at \begin{document} then margin linenumbers still appear in the margin of the convtran lines :(
    – jan
    Jun 12, 2022 at 16:37
  • @jan Answer updated. With the help of \ifLineNumbers, now it should work. Jun 12, 2022 at 19:49
  • 1
    It does :) Thanks so much! Fragile or not, it does the job. I would hope the convtran maintainer would use this for creating linenumbers in the style itself (as the way in which it uses the linenumbers mechanism currently doesn't seem to be the ideal way of doing things anyways ...)
    – jan
    Jun 12, 2022 at 20:40
  • 2
    Thanks. I have incorporated this code into the package. Since the package meets most of my needs I don't generally spend time on it, but I am well aware it could be improved. Any improvements gratefully received. Jul 12, 2022 at 18:57
0

In the mentioned convtran.sty, the tag \linenumbersep controls the spacing of linenumbers, you can modify it what ever you like, and the modified MWE is:

\documentclass{report}    
\usepackage{convtran}
\usepackage{lipsum}

\begin{document}
\setlength\linenumbersep{20pt}
\linenumbers
\lipsum[4]

\begin{convtran}
    \turn{A:} Hello 
    \turn{B:} Hello 
\end{convtran}

\lipsum[4]
\end{document}
1
  • 1
    Thanks so much for your reply. The issue is that \linenumbersep controls the spacing globally. What I'm hoping to achieve (and what I've now clarified in the question), is to have two independent sets of linenumbers on in the margins and one for the transcripts, each with independent parameters ...
    – jan
    Apr 21, 2022 at 15:43

You must log in to answer this question.

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