0

If I use lettrine inside a paracol environment and parindent is set to 0mm, the following problem arises if the paragraph on both sides is just one line:

There is no indentation in the next line and the text is overlapping with the text of lettrine.

How can I detect the paragraphs that consists of just one line and automatically add the needed indentation for the next paragraph? (Lettrine is used about 2000 times in documents with different page width, manual adjustment is not an option.)

enter image description here

    \documentclass[a5paper,twoside]{article}
    \usepackage{geometry}
    \usepackage{paracol}
    \usepackage{lettrine}
    
    \setlength{\columnsep}{3mm}
    \setlength{\parindent}{0mm}
    
    \begin{document}
    
    \begin{paracol}{2}
    \switchcolumn[0]
    
    \lettrine{1}
    Not much text
    
    \switchcolumn
    
    \lettrine{1}
    And again
    
    \switchcolumn*
    
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    
    \switchcolumn
    
    Some other text
    Some other text
    Some other text
    Some other text
    Some other text
    Some other text
    Some other text
    
    \switchcolumn*
    
    \lettrine{2}
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    Some text
    
    \switchcolumn
    
    \lettrine{2}
    Some other text
    Some other text
    Some other text
    Some other text
    Some other text
    Some other text
    Some other text
    
    \switchcolumn*
    
    \end{paracol}
    
    \end{document}

As @John Kormylo pointed out, this is not a problem of paracol.

My solution, based on his answer, is as follows:

enter image description here

\documentclass[a5paper,twoside]{article}
\usepackage{geometry}
\usepackage{paracol}
\usepackage{lettrine}
\usepackage{lipsum}

\setlength{\columnsep}{3mm}
\setlength{\parindent}{0mm}

\newlength{\CLFL}% Custom length for lettrine
\newlength{\IFLL}% Indentation for lettrine left
\newlength{\IFLR}% Indentation for lettrine right
\setlength{\IFLL}{0pt}
\setlength{\IFLR}{0pt}

\makeatletter
\newcommand{\lettrineLeft}[2]% #1=letter, #2=paragraph
{\bgroup
    \setbox0=\vbox{\lettrine{#1}{}{\global\CLFL=\dimexpr \L@height-\L@lraise-\ht\strutbox} #2}%
    \setlength{\@tempdima}{\dimexpr \CLFL-\ht0-\dp0}
    \ifdim\@tempdima> -10pt
    \setbox0=\hbox{\lettrine{#1}{}{\global\IFLL=\dimexpr\L@Nindent-0.5\fontdimen2\font\space}}
    \fi
    \egroup
    \lettrine{#1}{} #2}
\makeatother

\makeatletter
\newcommand{\lettrineRight}[2]% #1=letter, #2=paragraph
{\bgroup
    \setbox0=\vbox{\lettrine{#1}{}{\global\CLFL=\dimexpr \L@height-\L@lraise-\ht\strutbox} #2}%
    \setlength{\@tempdima}{\dimexpr \CLFL-\ht0-\dp0}
    \ifdim\IFLL> 0pt
    \ifdim\@tempdima> -10pt
    \setbox0=\hbox{\lettrine{#1}{}{\global\IFLR=\dimexpr\L@Nindent-0.5\fontdimen2\font\space}}
    \fi
    \else
    \global\setlength{\IFLL}{0pt}
    \fi
    \egroup
    \lettrine{#1}{} #2}
\makeatother

\newcommand{\indentLeft}{\ifdim\IFLL> 0pt \hskip\IFLL\global\setlength{\IFLL}{0pt}\fi}
\newcommand{\indentRight}{\ifdim\IFLR> 0pt \hskip\IFLR\global\setlength{\IFLR}{0pt}\fi}

\begin{document}
    
    \begin{paracol}{2}\sloppy
        \switchcolumn[0]
        
        \lettrineLeft{100}{Not much text here.}
        
        \switchcolumn
        
        \lettrineRight{1}{NAnd again}
        
        \switchcolumn*
        
        \indentLeft Some text..a
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        
        \switchcolumn
        
        \indentRight Some other text
        Some other text
        Some other text
        Some other text
        Some other text
        Some other text
        Some other text
        
        \switchcolumn*
        
        \lettrineLeft{2}{Some text
            Some text
            Some text
            Some text
            Some text
            Some text
            Some text
            Some text
            Some text}
        
        \switchcolumn
        
        \lettrineRight{2}{Some other text
            Some other text
            Some other text
            Some other text
            Some other text
            Some other text
            Some other text}
        
        \switchcolumn*
        
        \indentLeft
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        Some text
        
        \switchcolumn
        
        \indentRight
        Some other text
        Some other text
        Some other text
        Some other text
        Some other text
        Some other text
        Some other text
        
        \switchcolumn*
        
    \end{paracol}
    
\end{document}
2
  • Not sure that paracol matters in this. The problem is detecting the end of a paragraph without running into \end{document} or some such. Feb 17 at 21:18
  • You're right, this has nothing to do with paracol.
    – Ben
    Feb 18 at 11:45
0

This solution requites you to add the entire paragraph as an argument. The computation is based of fooling around with different length registers until it looked right.

One should always end a paragraph with \strut before \switchcolumn* or other commands which break \baselineskip.

\documentclass[a5paper,twoside]{article}
\usepackage{geometry}
\usepackage{paracol}
\usepackage{lettrine}
\usepackage{lipsum}

\setlength{\columnsep}{3mm}
\setlength{\parindent}{0mm}

\newlength{\Ltht}

\makeatletter
\newcommand{\latrine}[3]% #1=letter, #2=wirdm #3=rest of paragraogh
{\bgroup
  \setbox0=\vbox{\lettrine{#1}{#2}{\global\Ltht=\dimexpr \L@height-\L@lraise-\ht\strutbox} #3\strut}%
  \setlength{\@tempdima}{\dimexpr \Ltht-\ht0-\dp0}
  \ifdim\@tempdima> 0pt
    \unvbox0\vskip\@tempdima
  \else
    \unvbox0
  \fi
\egroup}
\makeatother  

\begin{document}

\begin{paracol}{2}
\switchcolumn[0]

\latrine{1}{}{Not much text}

\switchcolumn

\latrine{1}{}{And again}

\switchcolumn*

Some text
Some text
Some text
Some text
Some text
Some text
Some text
Some text
Some text\strut

\switchcolumn

Some other text
Some other text
Some other text
Some other text
Some other text
Some other text
Some other text\strut

\switchcolumn*

\latrine{2}{}{Some text
Some text
Some text
Some text
Some text
Some text
Some text
Some text
Some text}

\switchcolumn

\latrine{2}{}{Some other text
Some other text
Some other text
Some other text
Some other text
Some other text
Some other text}

\switchcolumn*

\end{paracol}

\end{document}
1
  • This did not exactly answer my question, but pointed me into the right direction. Therefore I accept your answer.
    – Ben
    Feb 18 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.