我有以下代码片段,并打算格式化如下:
\setmainfont[
UprightFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-Capt},
{Size={8.4-13},Font=MinionPro-Regular},
{Size={13-19.9},Font=MinionPro-Subh},
{Size={19.9-},Font=MinionPro-Disp}
},
{RawFeature = {protrusion = mnr}},
},
BoldFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldCapt},
{Size={8.4-13},Font=MinionPro-Bold},
{Size={13-19.9},Font=MinionPro-BoldSubh},
{Size={19.9-},Font=MinionPro-BoldDisp}
},
{RawFeature = {protrusion=mnrb}},
},
ItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-ItCapt},
{Size={8.4-13},Font=MinionPro-It},
{Size={13-19.9},Font=MinionPro-ItSubh},
{Size={19.9-},Font=MinionPro-ItDisp}
},
{RawFeature = {protrusion=mni}},
},
BoldItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldItCapt},
{Size={8.4-13},Font=MinionPro-BoldIt},
{Size={13-19.9},Font=MinionPro-BoldItSubh},
{Size={19.9-},Font=MinionPro-BoldItDisp}
},
{RawFeature = {protrusion=mnib}}
},
RawFeature={expansion=default},
]{Minion Pro}
但是,将其应用于包含上述代码的latexindent
文件.tex
会导致以下混乱:
\setmainfont[
UprightFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-Capt},
{Size={8.4-13},Font=MinionPro-Regular},
{Size={13-19.9},Font=MinionPro-Subh},
{Size={19.9-},Font=MinionPro-Disp}
},
{RawFeature = {protrusion = mnr}},
},
BoldFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldCapt},
{Size={8.4-13},Font=MinionPro-Bold},
{Size={13-19.9},Font=MinionPro-BoldSubh},
{Size={19.9-},Font=MinionPro-BoldDisp}
},
{RawFeature = {protrusion=mnrb}},
},
ItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-ItCapt},
{Size={8.4-13},Font=MinionPro-It},
{Size={13-19.9},Font=MinionPro-ItSubh},
{Size={19.9-},Font=MinionPro-ItDisp}
},
{RawFeature = {protrusion=mni}},
},
BoldItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldItCapt},
{Size={8.4-13},Font=MinionPro-BoldIt},
{Size={13-19.9},Font=MinionPro-BoldItSubh},
{Size={19.9-},Font=MinionPro-BoldItDisp}
},
{RawFeature = {protrusion=mnib}}
},
RawFeature= {expansion=default},
]{Minion Pro}
我能做些什么?
答案1
更新
作为V3.9.1该脚本默认提供以下输出,无需使用任何配置(SRSR333.yaml
),因此您只需运行
latexindent.pl myfile.tex
输出如下所示。
原始答案
默认设置允许在其名称中keyEqualsValuesBracesBrackets
包含{
,这会给您的示例带来问题。
我们可以fineTuning
在以下文件中使用该字段:
SRSR333.yaml
defaultIndent: ' '
fineTuning:
keyEqualsValuesBracesBrackets:
name: '[a-zA-Z@\*0-9_\/.\h:\#-]+?'
然后运行
latexindent.pl -l SRSR333.yaml myfile.tex
给出输出
\setmainfont[
UprightFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-Capt},
{Size={8.4-13},Font=MinionPro-Regular},
{Size={13-19.9},Font=MinionPro-Subh},
{Size={19.9-},Font=MinionPro-Disp}
},
{RawFeature = {protrusion = mnr}},
},
BoldFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldCapt},
{Size={8.4-13},Font=MinionPro-Bold},
{Size={13-19.9},Font=MinionPro-BoldSubh},
{Size={19.9-},Font=MinionPro-BoldDisp}
},
{RawFeature = {protrusion=mnrb}},
},
ItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-ItCapt},
{Size={8.4-13},Font=MinionPro-It},
{Size={13-19.9},Font=MinionPro-ItSubh},
{Size={19.9-},Font=MinionPro-ItDisp}
},
{RawFeature = {protrusion=mni}},
},
BoldItalicFeatures={
SizeFeatures={
{Size={-8.4},Font=MinionPro-BoldItCapt},
{Size={8.4-13},Font=MinionPro-BoldIt},
{Size={13-19.9},Font=MinionPro-BoldItSubh},
{Size={19.9-},Font=MinionPro-BoldItDisp}
},
{RawFeature = {protrusion=mnib}}
},
RawFeature={expansion=default},
]{Minion Pro}