Latexident 的意外縮減為

Latexident 的意外縮減為

我有以下文件,它是我的自訂類別之一的一部分:

% 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關閉

Latexident.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

相關內容