0

I'm aware that I can change the color of elements globally with e.g. \renewcommand {\umltextcolor}{red}. How could I give individual elements different colours or fonts? Assume the example below, where I want to give the IMyInterface box a blue background, and change the font of MyImplementation to monospace.

\documentclass[tikz]{standalone}

\usepackage[simplified]{pgf-umlcd} \usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\begin{interface}{IMyInterface}{0,0} \end{interface}

\begin{class}{MyImplementation}{0,-2} \implement{IMyInterface} \end{class}

\end{tikzpicture}

\end{document}

Edit:

One way to at least style the fill, text, and line colour is to explicitly specify \renewcommand {\umlfillcolor}{Red} etc. before each element. I still wonder if there is a better way, and a way to alter the font face itself.

Lennart
  • 394

1 Answers1

1

You can pass any option that is available for TikZ nodes to the pgf-umlcd elements as an optional argument to the environment. An example is given in the manual with the TikZ option text width:

\begin{class}[text width=8cm]{ClassName}{0 ,0}

In this case you can use the options fill and font.

MWE:

\documentclass[tikz]{standalone}

\usepackage[simplified]{pgf-umlcd} \usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\begin{interface}[fill=blue!20]{IMyInterface}{0,0} \end{interface}

\begin{class}[font=\ttfamily]{MyImplementation}{0,-2} \implement{IMyInterface} \end{class}

\end{tikzpicture}

\end{document}

Result:

enter image description here

Marijn
  • 37,699