latexindent による予期しないインデント動作

latexindent による予期しないインデント動作

私のカスタム クラスの 1 つに含まれる次のファイルがあります。

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

ここでご覧になるソースコードは、 を実行した後の正確な出力ですlatexindent。ただし、代わりに次のような出力が得られると予想されます。

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

明らかに、latexindent私の設定に従って、セクション コマンドをインデントするためのルールをここに適用しています。

# 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

私はセクションをインデントするのが好きですが、定義をインデントするのは好きではありません。また、latexindent定義をインデントするように指示されたこともない気がします。明らかに、私の期待と実際の機能の間にはギャップがあります。

ここでの疑問は、latexindentセクションコマンドの定義に適用しないようにするにはどうすればいいかということです。

答え1

私のカスタムクラスの一部である次のファイルがあります

これはクラスファイルの一部なので、indentAfterHeadings次のようにオフにすることをお勧めします。

ラテックスインデント.yaml

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

そして実行する

latexindent.pl -l myfile.tex

yamlファイルを別の名前にしたい場合は、marc.yaml次のようにします。

latexindent.pl -l marc.yaml myfile.tex

関連情報