# How to align visibility in pgf-umlcd?

code here-

\documentclass{standalone}
\usepackage{pgf-umlcd}
\begin{document}
\begin{tikzpicture}
\begin{class}[text width = 8cm]{JavaLanguageBehavior}{0,0}
\attribute{$\sim$ com.alhelal.textpad}
\attribute{- uniqueInstance : JavaLanguageBehavior}
\operation{+ getUniqueInstance : JavaLanguageBehavior}
\operation{+ runCode(file : File) : BufferedReader}
\operation{+ buildCode(file : File) : BufferedReader}
\operation{+ setHighlightableText()}
\operation{+ setAutoCompletableText()}
\end{class}
\node [above=3mm] at (current bounding box.north) {Singleton Pattern};
\end{tikzpicture}
\end{document}

When I use a -(private) as visibility the uniqueInstance variable goes to left. How can I align the visibility and variables?

Presumably you want to use $-$, so that it becomes a minus sign instead of a hyphen, which in turn means that the widths are similar.

For consistency, set the plus signs in math mode as well.

\documentclass{standalone}
\usepackage{pgf-umlcd}
\begin{document}
\begin{tikzpicture}
\begin{class}[text width = 8cm]{JavaLanguageBehavior}{0,0}
\attribute{$\sim$ com.alhelal.textpad}
\attribute{$-$ uniqueInstance : JavaLanguageBehavior}
\operation{$+$ getUniqueInstance : JavaLanguageBehavior}
\operation{$+$ runCode(file : File) : BufferedReader}
\operation{$+$ buildCode(file : File) : BufferedReader}
\operation{$+$ setHighlightableText()}
\operation{$+$ setAutoCompletableText()}
\end{class}
\node [above=3mm] at (current bounding box.north) {Singleton Pattern};
\end{tikzpicture}
\end{document}
• Thank you. I guessed that you will answer. But should I need $+$ for + instead of only +? Nov 1, 2017 at 14:03
• @alhelal Didn't seem to make a difference in this case, I did it just for consistency. But it will depend on font setup, if you're using a math font with smaller plus/minus signs you could see a small difference. Nov 1, 2017 at 14:08
• Yes. Consistency is important. I recommend you to mention this in answer why you write extra \$. Thank you. Nov 1, 2017 at 14:15