7

I would like a fancy items where I can put or a icon or a progressive number with a triangle (see red arrow) that it shows the important item:

enter image description here

I only managed to build this at the time.

enter image description here

\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}

I thank everyone who can help me and thank you for your patience.

  • Sincerely and honestly nothing and I hope you appreciate it. I do not want others to do what I ask. I'm undecided whether to build a macro for the numeric list or to use the tcolorbox package. Peraphs I will try with TikZ. This period I have a very tired head for school and I do not get anything fast to create. I am not very fast like you who are very good as users. Apparently my sincerity was not appreciated. – Sebastiano May 7 '18 at 21:45
  • 2
    My problem with those graphics question only containing an image is that the requirements for a solution are extremely unclear. In your case, a solution for printed output in, say article, would look radically different from a solution for a presentation using beamer (you could use overlays). That is also why I stopped answering such questions and usually vote to close as unclear, as usually it is just wasted time for the person answering because the posted solution will probably not fit the (unknown) requirements and just be left unused. – Henri Menke May 7 '18 at 22:38
  • 1
    @Sebastiano To illustrate the Henri Menke's comment, imagine that you replace "Write your text here" or "List item" by \lipsum (from lipsum package)... What would be the desired result? – Paul Gaborit May 7 '18 at 22:57
  • 1
    For instance, for simple "List items" with few words a solution could be also as simple as \menu{ X > List item} (menukeys package) but that not will work if the items are paragraphs. In this case, the arrow sould point to the first line or to the paragraph center ? an so on ... – Fran May 8 '18 at 20:13
9

Here is a very naive and brute force proposal.

\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}

enter image description here

ADDENDUM: Brackets and colors. (Of course, if you have longer lists, you need to either extend the color list, or implement some mod condition.)

\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}

enter image description here

  • Dear, thank you. I voted for your answer positively. I ask you if it is possible after the numbering to put the round bracket as in my code that I entered only today. I'm on tilt! – Sebastiano May 9 '18 at 8:37
  • 1
    @Sebastiano You just need to change this line \renewcommand{\labelenumi}{\SebastianoItem{\arabic{enumi})}} – caverac May 9 '18 at 9:59
  • @Sebastiano What caverac is suggesting would work. – user121799 May 9 '18 at 13:06
  • Surely it will work: Caverac like everyone (except me) you are very good. I am undecided who put the check. You are great and for my honesty I would not make a "disrespect" to anyone. I'm sorry for the immediate negative votes I've had. – Sebastiano May 9 '18 at 21:12
  • @marmot See my comments to Steven. I have checked your answer. – Sebastiano May 11 '18 at 13:04
6

Without tikz.

Here I introduce the bangenumerate environment, in which emphasized items are invoked with \item! instead of \item. The optional argument of \item is still supported.

(Note: the syntax \item[]! has no meaning, as the ! directive is overridden with the optional label. )

Color can be changed mid stream with an invocation of \colorlet{bangcolor}{...} between \items.

EDITED to \smash the label, so that larger values of \fboxsep can be employed without affecting line spacing.

\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}

enter image description here

  • If one wants to live dangerously, one can change all occurrences of bangenvironment to !environment and it will still work. – Steven B. Segletes May 9 '18 at 18:10
  • Your answer and that of marmot are beautiful and wonderful. I'm in confusion now. I voted for your answers. But is it possible to put a green check for both answers? :-) May I ask you a favor, could you edit your code and put the parentheses in the enumeration? Thank you so much. I'm sorry for the immediate negative votes I've had. – Sebastiano May 9 '18 at 21:09
  • @Sebastiano I just added a ) after \theenumi and that did it. – Steven B. Segletes May 10 '18 at 0:20
  • You are also a great!!!! Both my and marmot's answers are very good for me. They are at the same level. For my nature I do not want to spite or privilege knows to you both a marmot and I will not put green check. – Sebastiano May 11 '18 at 12:58
  • @Sebastiano Please, give it to marmot. There is no insult taken. A mere friendly competition. – Steven B. Segletes May 11 '18 at 13:01

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.