8

Problem:

I am trying to find a way to customise enumerate items. Basically I want to keep the standard version but also want to change certain items to color boxes.

Minimal Working Example:

\documentclass[14pt]{beamer}
\begin{document}

\setbeamertemplate{enumerate item}{%
  \usebeamercolor[bg]{item projected}%
  \raisebox{1.5pt}{\colorbox{bg}{\color{fg}\footnotesize\insertenumlabel}}%
}

\begin{frame}
\begin{enumerate}
  \item Enum
  \item Enum
  \item Enum
\end{enumerate}
\end{frame}


\end{document} 

Outputs:

enter image description here

Desired output:

enter image description here

Basically I want to be able to change the color of a specific enumerate box. The text that follows the item should always be vertically centered.

Update 1:

\documentclass{article}

\usepackage{xcolor}
\usepackage[shortlabels]{enumitem}

\newcommand{\specialitem}[3][white]{%
  \item[%
    \colorbox{#2}{\textcolor{#1}{\makebox(14,14){#3}}}%
  ]
}

\definecolor{editorOrange}{cmyk}{0, 0.8, 1, 0}
\definecolor{editorBlue}{cmyk}{1, 0.6, 0, 0}
\definecolor{editorGreen}{cmyk}{0.66, 0, 0.87, 0}
\definecolor{editorPink}{cmyk}{0, 1, 0, 0}

\begin{document}

\setlist[enumerate,1]{leftmargin=9mm}

\begin{enumerate}
  \specialitem{editorPink}{H} \textcolor{editorPink}{Hyper} lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor metus ac fermentum rutrum. Phasellus convallis scelerisque nulla, eu sollicitudin diam rutrum id. Curabitur dapibus dapibus nisl ac tempus. Praesent viverra tortor a mollis efficitur. Donec vehicula risus nec varius ornare. Suspendisse facilisis ante eu ex ultricies viverra.

  \specialitem{editorBlue}{T} \textcolor{editorBlue}{Text} lorem ipsum dolor sit amet, consectetur adipiscing elit.

  \specialitem{editorOrange}{M} \textcolor{editorOrange}{Markup} lorem ipsum dolor sit amet, consectetur adipiscing elit.lorem ipsum dolor sit amet, consectetur adipiscing elit.lorem ipsum dolor sit amet, consectetur adipiscing elit.

  \specialitem{editorGreen}{L} \textcolor{editorGreen}{Language} lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{enumerate}

\end{document}

Update 1 (output):

enter image description here

8

Set the items manually inside an itemize. Below I defined \specialitem[<text colour>]{<colour>}{<content>} to act like \item:

enter image description here

\documentclass{beamer}

\setbeamertemplate{enumerate item}{%
  \usebeamercolor[bg]{item projected}%
  \raisebox{1.5pt}{\colorbox{bg}{\color{fg}\footnotesize\insertenumlabel}}%
}
\newcommand{\specialitem}[3][white]{%
  \item[%
    \colorbox{#2}{\textcolor{#1}{\makebox[1em]{#3}}}%
  ]
}

\begin{document}

\begin{frame}
\begin{enumerate}
  \item Enum
  \item Enum
  \item Enum
\end{enumerate}

\begin{itemize}
  \specialitem{red!80}{H} \textcolor{red!80}{Here} is an item

  \specialitem{blue!60!white}{T} \textcolor{blue!60!white}{This} is another item

  \specialitem{orange!80!white}{M} \textcolor{orange!80!white}{Maybe} another item

  \specialitem{green!70!white}{L} \textcolor{green!70!white}{Let} me show you another item
\end{itemize}

\end{frame}
  • Proposal: If the width of the boxes would equal \newlength{\Xheight} \settoheight{\Xheight}{X} they would seem more symmetric? – user36296 Aug 16 '16 at 17:31
  • @samcarter: The current width is consistent at 1em. One could add a \strut as part of the definition to ensure the same height, or a \vphantom{X}. No need to define a new length. – Werner Aug 16 '16 at 17:35
  • 1
    @Werner I have added an update and for some reason my version does not center the boxes in line with the text. The boxes are elevated. Is there a way to fix this? – kexxcream Aug 16 '16 at 17:47
  • 1
    @kexxcream: You're using \makebox(x,y). Use \makebox[1em]. – Werner Aug 16 '16 at 17:51
  • 1
    @kexxcream: Add \strut... \makebox[1em]{\strut#3}. – Werner Aug 16 '16 at 17:57

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.