cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
867 stars 84 forks source link

Linebreaks after items with overlay specifications of beamer #466

Closed nils-schween closed 1 year ago

nils-schween commented 1 year ago

Hi and thanks for developing latex indent,

I am currently creating a beamer presentation and I noticed that there are no line breaks after items in an itemize environment with overlay specifications.

original .tex code

  \begin{itemize}
    \item<1-> The acceleration and the transport of charged particles (Cosmic rays) is modelled with
      the \enquote{transport equation}.
    \item<2-> The transport equation is a Vlasov-Fokker-Planck (VFP) equation combined with the
      diffusion approximation, i.e. an almost isotropic distribution function.
    \item<3-> Anisotropies play an important role in, for example, the feedback of
      charged particles onto the accelerating plasma.
    \item<4-> We have two aims:
      \begin{enumerate}
        \item<6-> \textbf<8->{leaving the diffusion approximation behind} and
        \item<7-> computing the feedback of the Cosmic rays.
      \end{enumerate}
  \end{itemize}

My current yaml settings are

defaultIndent: "  "
lookForAlignDelims:
  split: 1
modifyLineBreaks:
  textWrapOptions:
    columns: 20

The ouput of latexinden is

\begin{frame}
  \frametitle{Modelling the acceleration process of Cosmic Rays}
  \begin{itemize}
    \item<1-> The acceleration and the transport of charged particles (Cosmic rays) is modelled with
      the \enquote{transport equation}.
    \item<2-> The transport equation is a Vlasov-Fokker-Planck (VFP) equation combined with the
      diffusion approximation, i.e. an almost isotropic distribution function.
    \item<3-> Anisotropies play an important role in, for example, the feedback of
      charged particles onto the accelerating plasma.
    \item<4-> We have two aims:
      \begin{enumerate}
        \item<6-> \textbf<8->{leaving the diffusion approximation behind} and
        \item<7-> computing the feedback of the Cosmic rays.
      \end{enumerate}
  \end{itemize}

If I remove the overlay specifiactions, I get

  \begin{itemize}
    \item The acceleration
          and the transport
          of charged
          particles (Cosmic
          rays) is modelled
          with the
          \enquote{transport
            equation}.
    \item The transport
          equation is a
          Vlasov-Fokker-Planck
          (VFP) equation
          combined with the
          diffusion
          approximation, i.e.
          an almost isotropic
          distribution
          function.
    \item Anisotropies play
          an important role
          in, for example,
          the feedback of
          charged particles
          onto the
          accelerating
          plasma.
    \item We have two aims:
          \begin{enumerate}
            \item \textbf{leaving the diffusion approximation behind} and
            \item computing the
                  feedback of the
                  Cosmic rays.
          \end{enumerate}
  \end{itemize}

I would expect something similar for the items with overlay specifications. My latexindent version is 3.20.3

It tried the manipulate the blockFollows: other: field, but I was not able to construct a regex which includes the overlays. Thanks for your help. Nils

cmhughes commented 1 year ago

Thanks for this.

Can you try

blocksFollow:
           other: \\\]|\\item(?:\h|\[|<[^>]+?)
nils-schween commented 1 year ago

Thanks, for your quick reply. I just tested it. It unfortunately does not work. I attach my indent.log file.

INFO:  latexindent version 3.20.3, 2023-02-19, a script to indent .tex files
       latexindent lives here: /usr/share/texmf-dist/scripts/latexindent/
       Thu Sep  7 14:11:34 2023
       Filename: vfp.tex
INFO:  Processing switches:
       -s|--silent: Silent mode active (you have used either -s or --silent)
       -wd|--overwriteIfDifferent: will overwrite ONLY if indented text is different
       -m|--modifylinebreaks: modify line breaks
INFO:  Directory for backup files and indent.log:
       .
INFO:  YAML settings read: defaultSettings.yaml
       Reading defaultSettings.yaml from /usr/share/texmf-dist/scripts/latexindent/defaultSettings.yaml
INFO:  YAML reading settings
       Home directory is /home/schween
       latexindent.pl didn't find indentconfig.yaml or .indentconfig.yaml
       see all possible locations: https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html#indentconfig-options)
INFO:  -l switch used without filename, will search for the following files in turn:
       localSettings.yaml,latexindent.yaml,.localSettings.yaml,.latexindent.yaml
INFO:  YAML settings read: -l switch
       Multiple localSettings found, separated by commas:
       localSettings.yaml, latexindent.yaml, .localSettings.yaml, .latexindent.yaml
       Adding ./.latexindent.yaml to YAML read paths
INFO:  YAML settings, reading from the following files:
       Reading USER settings from ./.latexindent.yaml
       ---
       defaultIndent: '  '
       lookForAlignDelims:
         split: '1'
       modifyLineBreaks:
         textWrapOptions:
           blocksFollow:
             other: \\\]|\\item(?:\h|\[|<[^>]+?)
           columns: '20'
       onlyOneBackUp: '1'

INFO:  Phase 1: searching for objects
INFO:  Phase 2: finding surrounding indentation
INFO:  Phase 3: indenting objects
INFO:  Phase 4: final indentation check
INFO:  -wd switch active
       Original body matches indented body, NOT overwriting, no back up files created
INFO:  Output routine:
       Not outputting to file; see -w and -o switches for more options.
       --------------
INFO:  Please direct all communication/issues to:
        https://github.com/cmhughes/latexindent.pl
cmhughes commented 1 year ago

Using

defaultIndent: "  "
lookForAlignDelims:
  split: 1
modifyLineBreaks:
  textWrapOptions:
    columns: 20
    blocksFollow:
           other: \\\]|\\item(?:\h|\[|<[^>]+?>)

gives

\begin{itemize}
  \item<1-> The acceleration
    and the transport
    of charged
    particles (Cosmic
    rays) is modelled
    with the
    \enquote{transport
      equation}.
  \item<2-> The transport
    equation is a
    Vlasov-Fokker-Planck
    (VFP) equation
    combined with the
    diffusion
    approximation, i.e.
    an almost isotropic
    distribution
    function.
  \item<3-> Anisotropies play
    an important role
    in, for example,
    the feedback of
    charged particles
    onto the
    accelerating
    plasma.
  \item<4-> We have two aims:
    \begin{enumerate}
      \item<6-> \textbf<8->{leaving the diffusion approximation behind} and
      \item<7-> computing the
        feedback of the
        Cosmic rays.
    \end{enumerate}
\end{itemize}
nils-schween commented 1 year ago

I am really sorry. It does work. I do not know what I did wrong yesterday. Thank you very much!