![latexindent 和尾随注释](https://linux22.com/image/405750/latexindent%20%E5%92%8C%E5%B0%BE%E9%9A%8F%E6%B3%A8%E9%87%8A.png)
在宏中,将百分号放在行尾是有意义的,以避免宏定义中出现任何换行符。例如,具有多行定义的宏可能如下所示:
\newcommand{\provideName}[3]{%
\providecommand{#1}{#2}%
\addto\captionsenglish{\renewcommand{#1}{#2}}%
\addto\captionsngerman{\renewcommand{#1}{#3}}%
}
现在我使用该latexindent
工具自动格式化我的代码。通常情况下,这种方法效果很好,但在这种情况下,格式化的代码如下所示:
\newcommand{\provideName}[3]{%
\providecommand{#1}{#2}%
\addto\captionsenglish{\renewcommand{#1}{#2}}%
\addto\captionsngerman{\renewcommand{#1}{#3}}%
}
为什么会产生这些额外的换行符?我该如何关闭此行为?(百分号是常见的做法,对吧?或者我可以安全地删除它们吗?)
本地设置.yaml
defaultIndent: ' '
onlyOneBackUp: 1
modifyLineBreaks:
textWrapOptions:
columns: 78
latexindent 参数
latexindent -w -m --cruft=build --local=./localSettings.yaml myfile.sty
更新了 localSettings.yaml
根据 cmhughes 的建议,我添加了perCodeBlockBasis
获取选项:
defaultIndent: ' '
onlyOneBackUp: 1
modifyLineBreaks:
textWrapOptions:
columns: 78
perCodeBlockBasis: 1
这导致 texlive-2017 下的代码如下:
\newcommand{\provideName}[3]{%
\providecommand{#1}{#2}%
\addto\captionsenglish{\renewcommand{#1}{#2}}%latexindenttrailingcomment36-EN
D
\addto\captionsngerman{\renewcommand{#1}{#3}}%latexindenttrailingcomment37-EN
D
}