0

In order to fit an UML diagram made with TiKZ-UML (https://perso.ensta-paris.fr/~kielbasi/tikzuml/) into a beamer slide, I am currently trying to shrink the body part of the components. Unfortunately, I did not find a way to do so.

My code looks like this:

\documentclass[aspectratio=169]{beamer}

\usepackage{tikz}

\usepackage{tikz-uml}

\usepackage{parts/umldocument} \usepackage{parts/umlmultidocument} \usepackage{parts/umlcomponent}

\begin{document}

\begin{frame}{Example UML Components} \begin{tikzpicture}

\begin{umlcomponent}{A} \hspace{-1cm} \end{umlcomponent}

\umlbasiccomponent[x=3, minimum height=0pt] {B}

\umlbasiccomponent[x=6, inner ysep=0pt] {C}

\umlbasiccomponent[x=9, outer ysep=0pt] {D}

\end{tikzpicture} \end{frame}

\end{document}

but this only creates the following output:

Four Components Without Reduced Size (except C, which is broken)

While setting inner ysep=0pt (from TikZ-UML: How to shrink lost space within classes?) reduces the size, it reduces the size of the overall component in a way that breaks its appearance. It is also possible to set inner ysep=-2pt, which further reduces the body, but it also reduces the header size.

Also adding

\tikzset{
  tikzuml component style/.append style={minimum height=0pt,inner ysep=0pt,text depth=2pt}
}

has no effect.

Has anybody an idea how to shrink the size of the body of an tikz-uml component, without breaking its header part?

1 Answers1

1

I came up myself with one intermediary solution: In tikz-uml.sty, one can adjust the line 4754 from

  \node[inner sep=2ex, font=\tikzumlDefaultFont, fit = \csname tikzumlComponentFit\tikzumlComponent@parent @@\tikzumlComponent@fitname\endcsname] (\tikzumlComponent@nodeName-body) {};%

to

  \node[inner sep=0ex, font=\tikzumlDefaultFont, fit = \csname tikzumlComponentFit\tikzumlComponent@parent @@\tikzumlComponent@fitname\endcsname] (\tikzumlComponent@nodeName-body) {};%

Thereby, the spacing is reduced.

This will affect all components in the picture (and the whole presentation), therefore a solution achieving to set the parameter from the outside would be much nicer.

  • 1
    If you're already editing the sty file you could say \node[every whatever node/.try, … and then use that style to set it from the outside. – Qrrbrbirlbel Sep 01 '22 at 11:00
  • Thanks for the hint, could you further specify the solution? My workaround solution is editing https://github.com/emanuelenardi/latex-packages/blob/163b733047c2824b8d802a460dbff59b75d8a095/tikz-uml/tikz-uml.sty#L4754, but I do not see which whatever node to edit (using tikzuml component style like in the question did not work). – David Georg Reichelt Sep 01 '22 at 12:22
  • You could just add an empty style to every \node at the end of the options and then you can (re)define that style outside and then TikZ would pick it up. If you use a key in the /tikzuml/component namespace you can define it in the optional argument of the umlcomponent environment and TikZ would pick it up. Say you change line 4754 so that it reads \node[…, /tikzuml/component/foo/.try] …; you should then be able to use \begin{umlcomponent}[foo/.style={fill=green}]. Or \pgfqkeys{/tikzuml/component/foo/.style=…} for a global approach. (Yes, I'd rewrite the class.) – Qrrbrbirlbel Sep 01 '22 at 13:06