Text FormattingItemize: bullet and text with the same color

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Molibdeno
Posts: 12
Joined: Fri Apr 07, 2017 12:15 pm

Itemize: bullet and text with the same color

Post by Molibdeno »

I'm trying to create a command to assign to an item and its text the same color

Code: Select all

\newcommand{\onecolor}[1] { \item[\color{#1}] \textcolor{#1}}
Where #1 is the chosen color
The result is text is colored, but the bullet is not displayed:

Image

Can you help me?

Complete code:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[
  a4paper,
  margin=15mm,
  bindingoffset=2mm,
  heightrounded,
]{geometry}

\usepackage{amsmath}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{enumitem}

\newcommand{\onecolor}[1] { \item[\color{#1}] \textcolor{#1}}

\definecolor{lightgray}{HTML}{EFEFEF}

\begin{document}


\begingroup\setlength{\fboxsep}{6pt}
\colorbox{white}{%
  \begin{varwidth}[t]{\textwidth}
  TRIGONOMETRIA
  \begin{itemize}

   \onecolor{pink}{$\cot 2\alpha = \cfrac{2 \cot^{2} \alpha - 1}{2 \cot \alpha}$}	

  \end{itemize}
  \end{varwidth}%
}\endgroup

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Itemize: bullet and text with the same color

Post by Stefan Kottwitz »

Welcome to the forum!

You provided a very good code example. So it's very easy to test.
This is a way to change the bullet color, while other bullets stay the same:

Code: Select all

\newcommand{\onecolor}[1]{\item[\textcolor{#1}{\labelitemi}]\textcolor{#1}}
Stefan
LaTeX.org admin
Post Reply