
動機
我正在使用該包普蘭圖姆爾繪製 uml 圖。不幸的是,plantuml(工具)的預設樣式很難看,我需要在每個 plantuml 環境中定義自訂樣式。為了避免經常重複樣式定義,我想定義一個使用 plantuml 環境並且已經包含樣式的自訂環境。不幸的是,我遇到了一些錯誤(詳細資訊如下)。
找到解決方法 - 不再需要解決方案
我發現 plantuml 支援主題。這些包含我需要的所有樣式,並且可以添加在一行中 - 即使重複,這對我來說也是可以接受的。出於學習目的,我仍然對想法感興趣,但我不再需要它們來解決原始問題。
MWE 與 plantuml 的標準用法
\documentclass{scrbook}
\usepackage{plantuml}
\begin{document}
\begin{plantuml}
@startuml % required by plantuml (the tool, not the package)
skinparam sequence { % style definition
ParticipantBorderColor black
ParticipantBackgroundColor white
}
Alice -> Bob: test % diagram content
@enduml
\end{plantuml}
\end{document}
我的方法
\documentclass{scrbook}
\usepackage{plantuml}
% environment definition
\newenvironment{bplantuml}{
\begin{plantuml}
@startuml
skinparam sequence {
ParticipantBorderColor black
ParticipantBackgroundColor white
}
}{
@enduml
\end{plantuml}
}
\begin{document}
% usage
\begin{bplantuml}
Alice -> Bob: test
\end{bplantuml}
\end{document}
錯誤
FancyVerb 錯誤:\begin{plantuml}[<key=value>] 和 d 行結尾之間存在無關輸入 `@startuml Skinparam sequence { ParticipantBorderColor blac k ParticipantBackgroundColor White } '
進一步的想法
用 makeatletter/makeatother 圍繞環境定義不起作用,儘管一旦原始問題得到解決,我可能仍然需要它?