# TikZ-UML: How to shrink lost space within classes?

I am using TikZ-UML to illustrate some concepts in a scientific paper. It does the job pretty well, but I have some space problems (as in all scientific papers, there is page limit). I already managed to shrink my figures by position in the concept properly, but there is a lot of lost space within the objects.

Consider the vertical space between the name of the objects in the figure, and the lines. There is something like 4 pt between the top of "A" and the line above it, for instance, and 6 pt below "A" as well.

Is there a way to control this space, in order to further shrink my figures?

Here is a minimal example of an object model made using tikz-uml:

\documentclass[a4paper]{article}
\usepackage{tikz-uml}
\begin{document}
\begin{center}
\begin{tikzpicture}
\umlsimpleclass{A}
\umlsimpleclass[x=2]{B}
\umlassoc{A}{B}
\end{tikzpicture}
\end{center}
\end{document}


By reading tikzuml.sty, I've seen a line:

\tikzstyle{tikzuml simpleclass style}=[rectangle, minimum height=2em, node distance=2em]%


I set the minimum height to 1em. This changes the lost space above "A" and "B", but not below

Thank you very much.

• Welcome to TeX.SE! We kindly suggest you to show a full minimal working example (MWE) on what you have worked so far, so we can help you further with your request. – Cragfelt Nov 15 '17 at 9:22
• Do you mean how to reduce the size of the blocks A, B, C? For instance you could use \node [block, minimum size=2mm] (Ablock) {A};. – Ilbant Nov 15 '17 at 9:30
• This means not using the tikZ-uml package; I was hoping to keep on using it actually. I was wondering how to tell tikz-uml to draw a smaller box around A for instance – Renaud De Landtsheer Nov 15 '17 at 9:51
• for instance, the object "A" is drawn using the primitive \umlsimpleclass{A} and it notably offers some support for routing the links between the boxes – Renaud De Landtsheer Nov 15 '17 at 9:56
• Please do make it a habit to include complete code examples when asking questions. In some cases it's entirely necessary to be able to solve a problem, and in cases like this it's just so much nicer to not have to make up a complete example from scratch. (I usually want and need to actually test code before posting.) – Torbjørn T. Nov 15 '17 at 10:19

There two or three things to modify for the nodes in question. (\umlclass in the end just makes a \node.) First, the minimum height, which is set to 2em by tikz-uml, and second the inner ysep, which determines the vertical distance from the node content to the node border.

So for example, if you do

\umlsimpleclass[x=2,minimum height=0pt,inner ysep=0pt]{A}


you get the output on the right, while the default is on the left:

There is still some space because the content is set in a tabular, i.e. you have a situation like

\node [inner ysep=0pt,draw] {\begin{tabular}{c}A\end{tabular}};


Another parameter to play with is text depth. Be aware of letters with descenders though (like y, g, j), if the text depth is too small, the letter might stick out of the node.

You can modify the styles tikzuml simpleclass style and tikzuml class style with e.g.

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


or make your own style that you add to the nodes where you want it.

Left is default, middle is modifying tikz-uml styles, right is with custom styles. They appear in that order in the code below.

\documentclass[border=10pt]{standalone}
\usepackage{tikz-uml}
\tikzset{
reduce height/.style={
minimum height=0pt,
inner ysep=#1,
text depth=2pt
},
reduce height/.default={0pt}
}
\begin{document}
\begin{tikzpicture}
\umlsimpleclass[x=-2]{Ay}
\umlclass[x=-2,y=-2]{B}{foo}{barg}
\umlclass[x=-2,y=-4]{B}{}{}

\begin{scope}[
% instead of a scope environment, you can add these style modifications
% in the options to a tikzpicture, or in \tikzset{} in the preamble
tikzuml simpleclass style/.append style={minimum height=0pt,inner sep=0pt},
tikzuml class style/.append style={minimum height=0pt,inner sep=0pt},
]
\umlsimpleclass{Ay}
\umlclass[y=-2]{B}{foo}{barg}
\umlclass[y=-4]{B}{}{}
\end{scope}

\umlsimpleclass[x=2,reduce height]{Ay}
\umlclass[y=-2,x=2,reduce height=1pt]{B}{foo}{barg}
\umlclass[y=-4,x=2,reduce height]{B}{}{}
\end{tikzpicture}
\end{document}