3

I have different symbols represent different cases for my study such as \triangledown, \vartriangle and \circ. I wanted to change the color of the symbol to represent different cases using rgb. I defined the color but only the color of the outline is changed only. I wanted the symbol to be filled with color too. Can anyone help?

Thank you

Before

\documentclass[]{article}
\usepackage{graphicx}
\usepackage{float}
\usepackage{gensymb}
\usepackage{amsmath,amssymb,latexsym}
\usepackage{color}
%%define color
\definecolor{light-gray}{rgb}{0.2,0.2,0.2}  
\definecolor{gray}{rgb{0.5,0.5,0.5} 
\definecolor{dark-gray}{rgb}{0.8,0.8,0.8}
\newcommand{\ulg}{{\color{light-gray}$\vartriangle$}}
\newcommand{\ug}{{\color{gray}$\vartriangle$}}
\newcommand{\udg}{{\color{dark-gray}$\vartriangle$}}
\newcommand{\dlg}{{\color{light-gray}$\triangledown$}}
\newcommand{\dg}{{\color{gray}$\triangledown$}}
\newcommand{\ddg}{{\color{dark-gray}$\triangledown$}}
\newcommand{\olg}{{\color{light-gray}$\circ$}}
\newcommand{\og}{{\color{gray}$\circ$}}
\newcommand{\odg}{{\color{dark-gray}$\circ$}}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Details of the computational mesh.}
\begin{tabular}{|l|c|c|c|c|}
\hline
    Case  & Symbol & S & h/l & N\textsubscript{cells} \\ \hline
     &  \ulg    &    &    &   \\ 
     &  \olg    &    &    &   \\ 
     &  \dlg    &    &    &   \\ \hline 
     &  \ug     &    &    &   \\
     &  \og     &    &    &   \\ 
     &  \dg     &    &    &   \\ \hline 
     &  \udg    &    &    &   \\
     &  \odg    &    &    &   \\ 
     &  \ddg    &    &    &   \\ \hline 
\end{tabular}%
\end{table}%
\end{document}
0

1 Answer 1

5

You need to change the used symbol and the used command to use the color:

\newcommand{\ulg}{\textcolor{light-gray}{$\blacktriangle$}} % <=========

Here I used command \textcolor to change the color of printed letter and command \blacktriangle to get the filled triangel.

To make the changing better seen I changed the color to

\definecolor{light-gray}{rgb}{1,0,0} % red

So with the complete code

\documentclass{article}

\usepackage{graphicx}
\usepackage{float}
\usepackage{gensymb}
\usepackage{amsmath,amssymb,latexsym}
\usepackage{color}
%%define color
\definecolor{light-gray}{rgb}{1,0,0} %  0.2,0.2,0.2
\definecolor{gray}{rgb}{0.5,0.5,0.5} % <=================== missing }
\definecolor{dark-gray}{rgb}{0.8,0.8,0.8}

\newcommand{\ulg}{\textcolor{light-gray}{$\blacktriangle$}} % <=========
\newcommand{\ug}{{\color{gray}$\vartriangle$}}
\newcommand{\udg}{\textcolor{light-gray}{$\blacktriangledown$}} % <======
\newcommand{\dlg}{{\color{light-gray}$\triangledown$}}
\newcommand{\dg}{{\color{gray}$\triangledown$}}
\newcommand{\ddg}{{\color{dark-gray}$\triangledown$}}
\newcommand{\olg}{{\color{light-gray}$\circ$}}
\newcommand{\og}{{\color{gray}$\circ$}}
\newcommand{\odg}{{\color{dark-gray}$\circ$}}


\begin{document}

\begin{table}[htbp]
\centering
\caption{Details of the computational mesh.}
\begin{tabular}{|l|c|c|c|c|}
\hline
    Case  & Symbol & S & h/l & N\textsubscript{cells} \\ \hline
     &  \ulg    &    &    &   \\ 
     &  \olg    &    &    &   \\ 
     &  \dlg    &    &    &   \\ \hline 
     &  \ug     &    &    &   \\
     &  \og     &    &    &   \\ 
     &  \dg     &    &    &   \\ \hline 
     &  \udg    &    &    &   \\
     &  \odg    &    &    &   \\ 
     &  \ddg    &    &    &   \\ \hline 
\end{tabular}%
\end{table}%

\end{document}

you get the wished result:

enter image description here

Check the needed symbols in file LaTeX_symbols.pdf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .