0

The doc of tikz-uml package says that the font size in diagrams could be changed by \tikzumlset{font=\footnotesize}, yet the font itself is not changed. I would like to change the font (in diagrams, not globally) from default style into mono style, say, monaco. Thanks!

BTW: I use XeLaTeX and \setmonofont{Monaco} to set global mono font.

  • 1
    \tikzumlset{font=\footnotesize\ttfamily} (leave out \footnotesize if the size change is not desired). – Paul Gessler Jan 21 '16 at 1:59
  • 1
    Welcome! Please provide everyone with a complete minimal example which can be compiled to illustrate the problem if @PaulGessler's suggestion does not solve the problem for you. – cfr Jan 21 '16 at 2:24
  • @PaulGessler's suggestion has solved my problem, many thanks! :) May I ask where to find documentations for such parameters (e.g. \ttfamily and others)? – oaheix Jan 21 '16 at 2:32
2

Simply add the font family command (here, \ttfamily) to the value of the font key along with the size command \footnotesize:

\documentclass{standalone}
\usepackage{tikz-uml}
\tikzumlset{font=\footnotesize\ttfamily}

\begin{document}
\begin{tikzpicture}
\umlclass{Test}{n = 1;}{}
\end{tikzpicture}
\end{document}

enter image description here

This solution is independent of how you select a particular monospaced font, whether by fontspec or by standard methods. \ttfamily will use whichever fixed-width font is selected by the rest of the code.

The reference page LaTeX font commands lists all available font commands for LaTeX. See the "activated by" column in the table there. In general, font families can be selected using a switch command that remains in effect for the entire group (such as \ttfamily here), or using a macro with an argument (such as \texttt{<text>}). In your use case, we use the switch command since TikZ will place these commands inside a group with the node contents.

| improve this answer | |
  • If there is a definitive reference for the font family commands here on-site, please let me know about it. I searched to no avail, but it'd be better to have an on-site link if possible. I did not put the full list here because it's really an aside to the question at hand. – Paul Gessler Jan 21 '16 at 2:49
  • As a newbie, I have learned a lot from your answer, thanks again for your kind help! :) – oaheix Jan 21 '16 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.