简体   繁体   中英

Embedding auto-generated UML diagrams to LaTeX output

Is it possible to embed the UML diagrams generated with UML_LOOK = YES in the LaTeX output?

Edit:

I am using Doxygen 1.9.1. The output of doxygen -x Doxyfile looks like this:

# Difference with default Doxyfile 1.9.1
PROJECT_NAME           = ...
JAVADOC_AUTOBRIEF      = YES
TOC_INCLUDE_HEADINGS   = 0
EXTRACT_ALL            = YES
EXTRACT_PRIVATE        = YES
INPUT                  = ...
FILE_PATTERNS          = *.cpp \
                         *.h
RECURSIVE              = YES
EXAMPLE_PATH           = .../examples
USE_MDFILE_AS_MAINPAGE = README.md
HTML_FORMULA_FORMAT    = svg
MATHJAX_RELPATH        = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
LATEX_CMD_NAME         = pdflatex
HAVE_DOT               = YES
COLLABORATION_GRAPH    = NO
UML_LOOK               = YES
TEMPLATE_RELATIONS     = YES
DOT_IMAGE_FORMAT       = svg
INTERACTIVE_SVG        = YES
DOT_TRANSPARENT        = YES

For a minimal source file like

class Lol {
    void foo(){}
};

class Bar : public Lol {
};

int main(int argc, char *argv[])
{
    
    return 0;
}

The HTML output contains this kind of diagram:

在此处输入图像描述

but the LaTeX PDF contains no graphs.

Edit 2

There seems to be a problem with dot ?

Executing external command `dot ".../html/classBar__inherit__graph.dot" -Tsvg -o ".../html/classBar__inherit__graph.svg"`
Executing external command `dot ".../latex/classLol__inherit__graph.dot" -Tpdf -o ".../latex/classLol__inherit__graph.pdf"`
Executing external command `dot ".../html/classLol__inherit__graph.dot" -Tsvg -o ".../html/classLol__inherit__graph.svg"`
Executing external command `dot ".../html/graph_legend.dot" -Tsvg -o ".../html/graph_legend.svg"`
Executing external commanerror: Failed to extract bounding box from generated diagram file .../latex/classLol__inherit__graph.pdf
error: Problems running dot: exit code=0, command='dot', arguments='".../latex/classLol__inherit__graph.dot" -Tpdf -o ".../latex/classLol__inherit__graph.pdf"'
error: Failed to extract bounding box from generated diagram file .../latex/classBar__inherit__graph.pdf
error: Problems running dot: exit code=0, command='dot', arguments='".../latex/classBar__inherit__graph.dot" -Tpdf -o ".../latex/classBar__inherit__graph.pdf"'
error: Failed to extract bounding box from generated diagram file .../latex/classBar__inherit__graph.pdf
error: problem writing FIG 0 figure!

A comment does not accept images, but when I run your example with doxygen 1.9.1 I do see the UML diagram in the LaTeX output:

在此处输入图像描述

and

在此处输入图像描述

I ran the given example with the extra option -d extcmd (so doxygen -d extmd ) which also showed me that the uml diagram was created.

Executing external command `dot ".../html/graph_legend.dot" -Tsvg -o ".../html/graph_legend.svg"`
Executing external command `dot ".../html/class_bar__inherit__graph.dot" -Tsvg -o ".../html/class_bar__inherit__graph.svg"`
Executing external command `dot ".../html/class_lol__inherit__graph.dot" -Tsvg -o ".../html/class_lol__inherit__graph.svg"`
Executing external command `dot ".../latex/class_bar__inherit__graph.dot" -Tpdf -o ".../latex/class_bar__inherit__graph.pdf"`
Executing external command `dot ".../html/inherit_graph_0.dot" -Tsvg -o ".../html/inherit_graph_0.svg"`
Executing external command `dot ".../latex/class_lol__inherit__graph.dot" -Tpdf -o ".../latex/class_lol__inherit__graph.pdf"`
Executing external command `dot ".../html/class_lol__inherit__graph.dot" -Tcmapx -o ".../html/class_lol__inherit__graph.map"`
Executing external command `dot ".../html/class_bar__inherit__graph.dot" -Tcmapx -o ".../html/class_bar__inherit__graph.map"`
Executing external command `dot ".../html/inherit_graph_0.dot" -Tcmapx -o ".../html/inherit_graph_0.map"`

So as far as I can see the UML diagrams are created.

Note: the current doxygen version is 1.9.5

Yes, it is possible, but Cairo 1.17.6 changes the way that the PDFs are encoded, and doxygen fails to process the PDFs generated by dot .

See https://github.com/doxygen/doxygen/issues/9319 , and albert's comment below (who figured this out, I am just summarizing the answer).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM