paracol 和 lettrine - 小段落的问题

paracol 和 lettrine - 小段落的问题

如果我lettrineparacol环境中使用并将parindent设置为0mm,则如果两边的段落都只有一行,则会出现以下问题:

下一行没有缩进,并且文本与 lettrine 的文本重叠。

我如何检测仅由一行组成的段落并自动为下一段添加所需的缩进?(Lettrine 在页面宽度不同的文档中使用了大约 2000 次,无法手动调整。)

在此处输入图片描述

    \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}

正如@John Kormylo 指出的那样,这不是的问题paracol

根据他的回答,我的解决方案如下:

在此处输入图片描述

\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\[email protected]\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\[email protected]\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}

答案1

此解决方案要求您将整个段落添加为参数。计算基于摆弄不同的长度寄存器,直到看起来正确为止。

应该始终使用\strutbefore\switchcolumn*或其他中断命令来结束一个段落\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}

相关内容