LaTeX forum ⇒ Text FormattingItemize: bullet and text with the same color

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

Itemize: bullet and text with the same color

Postby Molibdeno » Fri Apr 07, 2017 12:36 pm

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

  1. \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:

  1. \documentclass{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[italian]{babel}
  5. \usepackage[
  6. a4paper,
  7. margin=15mm,
  8. bindingoffset=2mm,
  9. heightrounded,
  10. ]{geometry}
  11.  
  12. \usepackage{amsmath}
  13. \usepackage{microtype}
  14. \usepackage{xcolor}
  15. \usepackage{varwidth}
  16. \usepackage{enumitem}
  17. \usepackage{hyperref}
  18. \usepackage{enumitem}
  19.  
  20. \newcommand{\onecolor}[1] { \item[\color{#1}] \textcolor{#1}}
  21.  
  22. \definecolor{lightgray}{HTML}{EFEFEF}
  23.  
  24. \begin{document}
  25.  
  26.  
  27. \begingroup\setlength{\fboxsep}{6pt}
  28. \colorbox{white}{%
  29. \begin{varwidth}[t]{\textwidth}
  30. TRIGONOMETRIA
  31. \begin{itemize}
  32.  
  33. \onecolor{pink}{$\cot 2\alpha = \cfrac{2 \cot^{2} \alpha - 1}{2 \cot \alpha}$}
  34.  
  35. \end{itemize}
  36. \end{varwidth}%
  37. }\endgroup
  38.  
  39. \end{document}

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 8206
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Fri Apr 07, 2017 4:36 pm

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:

  1. \newcommand{\onecolor}[1]{\item[\textcolor{#1}{\labelitemi}]\textcolor{#1}}


Stefan
Site admin


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 5 guests