5

I want to have an environment alike or identical to the itemize or enumerate environments in such a way that I be able to fully customize each item. For example, I want to use my very own defined "numberings" and every time I use the environment, my defined items to be placed automatically with respect to the corresponding index. Also, to make a little difference, I want to add something similar to the bullets in the "itemize" environment, but this time using some custom graphical shapes next to each item; the shapes may be diagrams of LaTeX or a piece of artwork imported using \includegraphics. I want to have a final output for the items similar to the following figure:

enter image description here

For example, by entering the following:

\begin{itemize}
\itemRectangle[itme 1]‎
\itemDiamond[item 2]‎
‎\itemRectangle‎[item 4]‎
\itemCustom[item 5]
\end{itemize}

I want an output alike the figure above in which the custom "numberings" to be automated are A, B, C and D which were perhaps previously defined using some LaTeX codes for a counter, and for the graphical shapes, for convenience, to be defined through a command like \includegraphics to insert the shape before the defined counter and the final part of the proposed command to be the name of the item. Appreciating in advance, I'm asking the qualified people to help me on this. Thank you.

  • 2
    You want ... a lot of things here ;-) – user31729 May 3 '16 at 19:42
  • @ChristianHupfer :-D, I only want to have a final output for the items similar to the figure above, thank you in advance. – Qaher May 3 '16 at 19:45
7

Since the OP wants a variety of unspecified icons, I'll leave the actual specification of those images to the OP. However, what I do here is create a custom environment geonumerate and the ability to specify item types with

\newitem{<Name>}{<content>}

When \itemName is called inside the geonumerate environment, it scales a version of <content> and makes it part of the label (thus, <content> can be any arbitrary size and will scale to the vertical footprint of a capital X.).

\documentclass{article}
\usepackage{enumitem,scalerel,graphicx}
\newlist{geonumerate}{enumerate}{1}
\setlist[geonumerate,1]{label={\protect\geoimage\,\Alph*.\protect\clearimage}}
\newcommand\newitem[2]{%
  \expandafter\newcommand\csname item#1\endcsname{%
    \gdef\geoimage{\scalerel*{#2}{X}}\item%
  }%
}
\def\clearimage{\gdef\geoimage{}}
\newitem{Rectangle}{\rule{2pt}{1pt}}
\newitem{Diamond}{\includegraphics{example-image-B}}
\newitem{Cross}{\includegraphics{example-image-C}}
\begin{document}
\begin{geonumerate}
\itemRectangle Foo
\itemDiamond Bar
\itemRectangle Is
\itemCross Nice
\item None of the above
\end{geonumerate}
\end{document}

enter image description here

10

Something like this?

I used tikz drawings, but this could be replaced by \includegraphics commands of course and a enumitem new list with a special counter named shapeenum has been defined with \AddEnumerateCounter, which selects the shapes according to the value.

Due to the internals of enumitem, the shape commands must be robust, i.e. use \DeclareRobustCommand{...} or \robustify (needs etoolbox then)

More shapes can be added easily, but in this case, a loop - like assignment of counter values and shapes is more appropiate, most likely.

\documentclass{article}


\usepackage{tikz}
\usetikzlibrary{shadings}
\usepackage{enumitem}


\DeclareRobustCommand{\shaperect}{
\begin{tikzpicture}[scale=0.15]
%  \draw (0,0) rectangle (2,1);
  \shadedraw[shading=color wheel] (0,0) rectangle (2,1);
\end{tikzpicture}
}

\DeclareRobustCommand{\shapediamond}{%
  \begin{tikzpicture}[scale=0.15]
%    \draw (-0.5,0) -- (0,0.5) -- (0.5,0) -- (0,-0.5) -- cycle;
    \shadedraw (-1,0) -- (0,1) -- (1,0) -- (0,-1) -- cycle;
  \end{tikzpicture}
}

\DeclareRobustCommand{\shapeplus}{%
  \begin{tikzpicture}[scale=0.15]
%    \draw (-1,-0.5) -- (-1,0.5) -- (-0.5,0.5) -- (-0.5,1) -- (0.5,1) -- (0.5,0.5) -- (1,0.5) -- (1,-0.5) -- (0.5,-0.5) -- (0.5,-1) -- (-0.5,-1) -- (-0.5,-0.5)-- cycle;
    \shadedraw[top color=red,bottom color=yellow] (-1,-0.5) -- (-1,0.5) -- (-0.5,0.5) -- (-0.5,1) -- (0.5,1) -- (0.5,0.5) -- (1,0.5) -- (1,-0.5) -- (0.5,-0.5) -- (0.5,-1) -- (-0.5,-1) -- (-0.5,-0.5)-- cycle;
  \end{tikzpicture}
}

\DeclareRobustCommand{\shapecircle}{%
  \begin{tikzpicture}[scale=0.2]
%    \draw circle(0.5);
    \shadedraw[top color=blue, bottom color=yellow] circle(0.5);
  \end{tikzpicture}
}



\makeatletter

\def\shapeenum#1{\expandafter\@shapeenum\csname c@#1\endcsname}

\def\@shapeenum#1{%
    \ifcase\number#1 % No number for 0
    \or
    \shaperect
    \or
    \shapediamond 
    \or
    \shapeplus
    \or
    \shapecircle
    \else
    \@ctrerr
    \fi
}


\AddEnumerateCounter*{\shapeenum}{\@shapeenum}{500}
\makeatother

\newlist{shapenum}{enumerate}{1}
\setlist[shapenum,1]{label={\shapeenum* \Alph*.}}
\begin{document}


\begin{shapenum}
\item Foo
\item Bar
\item Other
\item FooBar
%\item Error!  Will provide an error since not more than 4 shapes are defined
\end{shapenum}


\end{document}

enter image description here

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.