# Latex export - limitations?

Not sure what is beyond the capability of latex export and what might be a bug.

1. Font sizes don't seem to be respected.  For example:

@startuml

skinparam LegendBackgroundColor LightGrey
skinparam LegendFontSize 8

:A;

:B;

legend right
**References:**
# [[http://dx.doi.org/10.1056/NEJMoa1011923 Conroy et al. N Engl J Med 2011; 364:1817-25]]
# [[http://dx.doi.org/JCO.1997.15.6.2403 Burris et al. J Clin Oncol 1997; 15:2403-13]]
end legend

@enduml

The legend and the A and B are the same size.  Same applies to text elsewhere.  The legend box however is reduced in size, so the text doesn't fit.  It appears the uml gets its font from the latex document (if the document is serif its serif, if its sans its sans)

I'm not good with font sizing in latex!  But if I do: \footnotesize in front of the text in a node it is smaller.  So if plantuml could pass some text sizing info it should be possible.

From the example above the latex for the first line of legend is:

\node at (557.6215pt,973.5996pt)[below right,color=black]{1.};

\node at (566.4882pt,973.5996pt)[below right,color=plantucolor0004]{\underline{Conroy et al. N Engl J Med 2011; 364:1817-25}};

Manually 'hacking' that to:

\node at (557.6215pt,973.5996pt)[below right,color=black]{1.};

\node at (566.4882pt,973.5996pt)[below right,color=plantucolor0004]{\href{http://dx.doi.org/10.1056/NEJMoa1011923}{Conroy et al. N Engl J Med 2011; 364:1817-25}};

Gives me a link that opens (should probably actually leave the /underline as this isn't underlined.

(Needs \usepackages{hypperref} in the premble)

3. PNG image in header shows as NULL

The latex code for that is:

\node at (609.1542pt,10pt)[below right]{{null}};

So its plant that is providing the "NULL".

Replacing that with

\node at (609.1542pt,10pt)[below right]{\includegraphics{myLogo.png}};

Sort of works.  There is a scaling issue because I've scaled the whole think (see below) and this doesn't scale with it but its close to what I'd want.

4. Scaling the image to the page

Outputing a large (wide or tall) uml it runs off the end of the page.  I was able to wrap my code to scale it but it requires a manual edit...

... \begin{tikzpicture}[scale=\tikzscale, yscale=-1,

With this hack in the pre-amble

\usepackage{environ}

\makeatletter
\newsavebox{\measure@tikzpicture}
\NewEnviron{scaletikzpicturetowidth}[1]{%
\def\tikz@width{#1}%
\def\tikzscale{1}\begin{lrbox}{\measure@tikzpicture}%
\BODY
\end{lrbox}%
\pgfmathparse{#1/\wd\measure@tikzpicture}%
\edef\tikzscale{\pgfmathresult}%
\BODY
}
\makeatother

And then inputing the uml using:

\begin{scaletikzpicturetowidth}{\textwidth}
\input{myFlow.latex}
\end{scaletikzpicturetowidth}

And that is only scaling width not height.

Is there a better way to do this?

What I'm trying to achieve is a PDF document with 5 or 6 full A4 page size UMLs that may need scaled to fit (scale down, but not up).  They need clickable html links.  There will be a parallel set of SVGs which will be embedded in a website.  Those SVGs are clickable ().  The PNG logo is about attributing ownership and copyright info etc and so is needed in the SVGs where they are stand alone files if saved.  The PDF could have them in the other latex bit.

If latex could just import an SVG I'd probably be fine!

commented Feb 1 by (2,640 points)

You wrote: "If latex could just import an SVG I'd probably be fine!"

I think LaTeX can include svg images with \includesvg and \usepackage{svg}

commented Feb 1 by CALUM Polwart
Ah - yes.  so that /includesvg is actually a rather convoluted process that also doesn't deliver what it needs to!  It uses inkscape on the command line, and uses an inkscape plugin to convert to a tikz which is then inserted into the latex as I understand it!

Inkscape doesn't export the hyperlinks. (I therefore haven't even attempted to progress that any further as that (and ability to search text) are the main reason I wouldn't just export a high reason not to simply export a high res PNG and import that!

answered Feb 1 by CALUM Polwart

From the example above the latex for the first line of legend is:

<SNIP>

Gives me a link that opens (should probably actually leave the /underline as this isn't underlined.

(Needs \usepackages{hypperref} in the premble)

Looking at this post:

It appears this function should already exist but I'm not seeing it.  I haven't tested it in the sequence diagram, I'm using an activity-beta (link in the activity box and link in a legend).  But that sounds like this should work and doesn't.

answered Feb 1 by CALUM Polwart

1. Font sizes don't seem to be respected.  For example:

<SNIP>

The legend and the A and B are the same size.  Same applies to text elsewhere.  The legend box however is reduced in size, so the text doesn't fit.  It appears the uml gets its font from the latex document (if the document is serif its serif, if its sans its sans)

I'm not good with font sizing in latex!  But if I do: \footnotesize in front of the text in a node it is smaller.  So if plantuml could pass some text sizing info it should be possible.

Seems there was some discussion back in 2017 on trying to get boxes to size better (https://forum.plantuml.net/6495/wrong-class-widths-after-latex-export?show=6495#q6495)

Latex (IMHO) is odd in that you neither specify a font or a point size directly!  You specify sans or serif, and you specify size with a set of pre-defined names.

So you can select a sans font with: \textsf{Sample Text 0123}

So you can select a size with a named size: \small{this is small}

Back then the question of how to add 'Arial' as a font was asked.  You'd need to have this in the preamble:

\usepackage{fontspec}
\setsansfont{Arial}


And in the node:

{\sffamily This is a sample text in \textbf{Sans Serif Font Typeface}}


You'd need to compile with XeLatex.
https://www.overleaf.com/learn/latex/XeLaTeX

Setting the font size in point size...  (10pt is the font size, 12pt I think is the line spacing, the advice seems to be to make this 1.2x the font size)

\fontsize{10pt}{12pt}\selectfont{some text}

So building on my earlier example the snip of the legend should be something like:


\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
\begin{document}
\begin{tikzpicture}
\node at (557.6215pt,973.5996pt)[below right,color=black]
{\textsf
{
\fontsize{8pt}{9.6pt}\selectfont
{1. }
}
};

\node at (566.4882pt,973.5996pt)[below right]
{\textsf
{\fontsize{8pt}{9.6pt}\selectfont
{\href
{http://dx.doi.org/10.1056/NEJMoa1011923}
{Conroy et al. N Engl J Med 2011; 364:1817-25}
}
}
};
\end{tikzpicture}
\end{document}