1

I have the following file that is part of one of my custom classes:

% actual latexindent output:
\DeclareDocumentCommand {\chapterformat}  { } { \thechapter }
 \DeclareDocumentCommand {\sectionformat} { } {\thesection}
  \DeclareDocumentCommand \subsectionformat { } {\thesubsection}
    \DeclareDocumentCommand \subsubsectionformat {} {\thesubsubsection}
    \DeclareDocumentCommand \paragraphformat {} {\theparagraph}
    \DeclareDocumentCommand \subparagraphformat {} {\thesubparagraph}

The source code you see here is the exact output after running latexindent. However, instead I would expect to have an output like

% expected latexindent output:
\DeclareDocumentCommand {\chapterformat}  { } { \thechapter }
\DeclareDocumentCommand {\sectionformat} { } {\thesection}
\DeclareDocumentCommand \subsectionformat { } {\thesubsection}
\DeclareDocumentCommand \subsubsectionformat {} {\thesubsubsection}
\DeclareDocumentCommand \paragraphformat {} {\theparagraph}
\DeclareDocumentCommand \subparagraphformat {} {\thesubparagraph}

Obviously, latexindent is applying the rules for indenting sectioning commands here, as per my configuration:

# from latexindentconfig.yaml
indentAfterHeadings:
    part:
       indentAfterThisHeading: 0
       level: 1
    chapter:
       indentAfterThisHeading: 1
       level: 2
    section:
       indentAfterThisHeading: 1
       level: 4
    subsection:
       indentAfterThisHeading: 1
       level: 8
    subsection*:
       indentAfterThisHeading: 0
       level: 9
    subsubsection:
       indentAfterThisHeading: 0
       level: 10
    paragraph:
       indentAfterThisHeading: 0
       level: 11
    subparagraph:
       indentAfterThisHeading: 0
       level: 12

I like indenting the sectioning, but not the definitions, and I feel like I never told latexindent to indent my definitions. Clearly, there is a gap between my expectations and the actual functionality.

The question now is: How do I tell latexindent not to apply to the definitions of sectioning commands?

marc
  • 701
  • Perhaps a local file latexindent.yaml that turns off the switches for this file indentAfterThisHeading: 0 – cmhughes Jan 22 '24 at 12:43

1 Answers1

1

I have the following file that is part of one of my custom classes

Given that this is part of a class file, I'd recommend switching off the indentAfterHeadings as in

latexindent.yaml

indentAfterHeadings:
    chapter:
       indentAfterThisHeading: 0
    section:
       indentAfterThisHeading: 0
    subsection:
       indentAfterThisHeading: 0

and then run

latexindent.pl -l myfile.tex

If you'd like to call the yaml file something else, say marc.yaml then you'd call

latexindent.pl -l marc.yaml myfile.tex
cmhughes
  • 100,947