一种奇特而美丽的枚举类型

一种奇特而美丽的枚举类型

我想要一个可以放置的精美物品,或者一个带有三角形的图标或渐进数字(参见红色箭头),它显示重要物品:

在此处输入图片描述

我当时只设法建造了这个。

在此处输入图片描述

\documentclass{article}
\usepackage{xcolor}
\newcommand{\varitem}[3][black]{%
  \item[%
   \colorbox{#2}{\textcolor{#1}{\makebox(5.5,7){#3}}}%
  ]
}
\begin{document}

\begin{enumerate}
\varitem{red!40}{\textbf{1)}} My macro for personalized \textbf{enumerate}. 1) or 2) or 3) \ldots has been adding without 
\varitem{gray!40}{\textbf{2)}} an automatic enumeration.
\varitem{cyan!40}{\textbf{3)}} This is that I have tried, quickly, only this morning. 
\varitem{orange!40}{\textbf{4)}} It is very nice but not as the figure with the little arrow (for important enumerate).
\end{enumerate}

I have created this with different colours.

\end{document}

我感谢所有能帮助我的人,谢谢你们的耐心。

答案1

这是一个非常幼稚和蛮力的提议。

\documentclass{article}
\usepackage{tikz}
\newcommand{\SebastianoItem}[1]{\tikz[baseline=(SebastianoItem.base),remember
picture]{%
\node[fill=red!20,inner sep=4pt,font=\sffamily] (SebastianoItem){#1};}}
\newcommand{\SebastianoHighlight}{\tikz[overlay,remember picture]{%
\fill[red!20] ([yshift=4pt,xshift=-\pgflinewidth]SebastianoItem.east) -- ++(4pt,-4pt)
-- ++(-4pt,-4pt) -- cycle;
}}
\begin{document}
\renewcommand{\labelenumi}{\SebastianoItem{\arabic{enumi}}}
Some basic rules.
  \begin{enumerate}
    \item Never put pineapple on a pizza!
    \item Never!!!! \SebastianoHighlight
    \item Trust me!
  \end{enumerate}
\end{document}

在此处输入图片描述

附录:括号和颜色。(当然,如果您有更长的列表,则需要扩展颜色列表,或实现一些 mod 条件。)

\documentclass{article}
\usepackage[x11names]{xcolor}
\usepackage{tikz}
% from https://tex.stackexchange.com/a/167024/121799
\newcommand{\ClaudioList}{red,DarkOrange1,Goldenrod1,Green3,blue!50!cyan,DarkOrchid2}
\newcommand{\SebastianoItem}[1]{\foreach \X[count=\Y] in \ClaudioList
{\ifnum\Y=#1\relax
\xdef\SebastianoColor{\X}
\fi
}
\tikz[baseline=(SebastianoItem.base),remember
picture]{%
\node[fill=\SebastianoColor,inner sep=4pt,font=\sffamily,fill opacity=0.5] (SebastianoItem){#1)};}
}
\newcommand{\SebastianoHighlight}{\tikz[overlay,remember picture]{%
\fill[\SebastianoColor,fill opacity=0.5] ([yshift=4pt,xshift=-\pgflinewidth]SebastianoItem.east) -- ++(4pt,-4pt)
-- ++(-4pt,-4pt) -- cycle;
}}
\begin{document}
\renewcommand{\labelenumi}{\SebastianoItem{\arabic{enumi}}}
Some general advices.
  \begin{enumerate}
    \item No fast food.
    \item Don't drink to much alcohol.
    \item No pineapple on pizza. \SebastianoHighlight
    \item Don't use onions in food.
  \end{enumerate}
\end{document}

在此处输入图片描述

答案2

没有tikz

这里我介绍了一种bangenumerate环境,其中强调的项目是用\item!而不是 来调用的\item。可选参数\item来调用。仍然支持 的

(注意:该语法\item[]!没有任何意义,因为!指令被可选标签覆盖。)

可以在流中途通过\colorlet{bangcolor}{...}调用\item

\smash标签进行编辑,以便\fboxsep可以使用更大的值而不影响行距。

\documentclass{article}
\usepackage{xcolor,enumitem,amssymb}
\let\svitem\item
\let\thebang\relax
\colorlet{bangcolor}{red!50}
\newenvironment{bangenumerate}
{%
  \fboxsep=3pt\relax%
  \renewcommand\item[2][\relax]{%
    \ifx!##2%
      \def\thebang{\makebox[0pt][l]{\kern-1pt\textcolor{bangcolor}{%
        \raisebox{1pt}{$\scriptstyle\blacktriangleright$}}}}%
      \def\next{}%
    \else%
      \def\thebang{}%
      \def\next{##2}%
    \fi%
    \ifx\relax##1\relax\svitem\else\svitem[##1]\fi\next%
  }%
  \begin{enumerate}[label={%
    \smash{\colorbox{bangcolor}{\bfseries\sffamily\theenumi)}\thebang}}]%
}{\end{enumerate}}
\begin{document}
\begin{bangenumerate}
\item My macro for personalized \textbf{enumerate}. 1) or 2) or 3) \ldots has been adding without 
\item automatic enumeration.
\item! This is that I have tried, quickly, only this morning. 
\item[OTHER] It is very nice but not as the figure with the little arrow (for important enumerate).
\item Should be normal without a bang
\colorlet{bangcolor}{blue!30}
\item! Color change with bang
\end{bangenumerate}
\end{document}

在此处输入图片描述

相关内容