乳胶中的 plantUML?

发布于 2025-01-12 20:46:39 字数 194 浏览 2 评论 0原文

是否可以在乳胶文档中使用 plantUML?

一种解决方法是将 plantUML 转换为 tikzpicture 并将其集成到 Latex 文档中。对我来说这似乎有点太多了,尤其是更新。

我正在使用 overleaf 和 TeXiFy,文档生成应该可以在两个乳胶编辑器上工作。

如果可以直接集成,我想看一个例子。

谢谢

Is it possible to use plantUML inside a latex document?

One workaround would be to convert plantUML into tikzpicture and integrate it in the latex document. That seems a bit too much effort to me, especially with updates.

I am using overleaf and TeXiFy, the document generation should work on both latex editors.

If a direct integration is possible, I would like to see an example.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错々过的事 2025-01-19 20:46:39

我首先回答你的第一个问题:
如果您使用 plantuml 包,您可以使用直接在 tex 文件中内联定义的 PlantUML 图。

考虑以下示例 test.tex 文件:

\documentclass{article}
\usepackage{plantuml}
\begin{document}
\section{PlantUML}

Let's insert a UML diagram:\\

\begin{plantuml}
  @startuml
  Alice -> Bob: TEST1
  @enduml
\end{plantuml}

And another one:\\

\begin{plantuml}
  @startuml
  Alice -> Bob: TEST2
  @enduml
\end{plantuml}
\end{document}

使用带有 -shell-escape 选项的 lualatex 生成 test.pdf ,如下所示:

test.pdf

现在你提到你使用texify 和 overleaf:

对于 texify,您需要像这样编辑命令:

texify --pdf --engine=lualatex --tex-option="-shell-escape" test.tex

overleaf 显然通过运行 plantuml 服务器来生成图表来支持 plantuml,这意味着您只需要在项目设置中将其设置为使用 lualatex 引擎。

-shell-escape 选项赋予 Latex 调用外部程序的权限,在我们的例子中,调用 java 来执行 plantuml 来生成我们想要的 plantuml 图。

请注意仅将 -shell-escape 与可靠的乳胶文件一起使用,以避免造成有害后果。

I will begin by answering your first question:
Yes you can use PlantUML diagrams directly defined inline in your tex file, if you use the plantuml package.

consider following example test.tex file:

\documentclass{article}
\usepackage{plantuml}
\begin{document}
\section{PlantUML}

Let's insert a UML diagram:\\

\begin{plantuml}
  @startuml
  Alice -> Bob: TEST1
  @enduml
\end{plantuml}

And another one:\\

\begin{plantuml}
  @startuml
  Alice -> Bob: TEST2
  @enduml
\end{plantuml}
\end{document}

use lualatex with the -shell-escape option to generate test.pdf which will look like this:

test.pdf

now you mentioned you use texify and overleaf:

for texify you would need to edit your command like so:

texify --pdf --engine=lualatex --tex-option="-shell-escape" test.tex

overleaf apparently supports plantuml by running a plantuml server for diagram generation, meaning you only need to set it to use the lualatex engine in the project settings.

The -shell-escape option gives latex permission to call foreign programs, in our case java is called to execute plantuml to produce the plantuml diagrams we want.

Be mindful to only use -shell-escape with trutworthy latex files to avoid harmful consequences.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文