Text FormattingAlternate images instead of bullets/numbers in a list

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
aurerua
Posts: 4
Joined: Wed Sep 22, 2010 11:22 am

Alternate images instead of bullets/numbers in a list

Post by aurerua »

Hi everyone,

I would like to use a set of images instead of bullets/numbers in a list as shown on the following image. Would there be a way to alternate between the images automatically for each new item in the list? Thank you.

Image
If the image is not visible, you can follow this link: https://docs.google.com/leaf?id=0B6dhuv ... j&hl=en_GB

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Alternate images instead of bullets/numbers in a list

Post by gmedina »

Hi,

I can't see the image and the link takes me to a blank page.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
aurerua
Posts: 4
Joined: Wed Sep 22, 2010 11:22 am

Alternate images instead of bullets/numbers in a list

Post by aurerua »

Sorry, it didn't work as I thought. Here is the image:
graphical-items.png
graphical-items.png (43.53 KiB) Viewed 8828 times
I managed to do it, I just wonder if there is a way to automate the alternation of images (so far I have for each new item to mention which image I want). I have 8 images and I would like that the first /item gets image 1, the second image 2, etc. and item 9 gets image one again, etc. without me having to specify the image directly...

Thanks!


Edit by localghost: No external links where applicable (see Board Rules). Attachments go onto the forum server.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Alternate images instead of bullets/numbers in a list

Post by localghost »

You could include the stars in your example as external images depending on the item counter of the list environment. Or draw them on your own with an appropriate graphics package.


Best regards and welcome to the board
Thorsten
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Alternate images instead of bullets/numbers in a list

Post by gmedina »

aurerua wrote:...I just wonder if there is a way to automate the alternation of images (so far I have for each new item to mention which image I want). I have 8 images and I would like that the first /item gets image 1, the second image 2, etc. and item 9 gets image one again, etc. without me having to specify the image directly...
Of course there is; name your images image0, image1, image2,..., image7 and then use the following code:

Code: Select all

\documentclass{article}
\usepackage{intcalc}
\usepackage{graphicx}

\newcommand*{\Myitem}{% 
  \item[\includegraphics{image\intcalcMod{\value{enumi}}{8}}]\stepcounter{enumi}% 
}
 
\begin{document}

\begin{enumerate}
  \Myitem First item.
  \Myitem Second item.
  \Myitem Third item.
  \Myitem Fourth item.
  \Myitem Fifth item.
  \Myitem Sixth item.
  \Myitem Seventh item.
  \Myitem Eighth item.
  \Myitem Ninth item.
  \Myitem Tenth item.
\end{enumerate}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
aurerua
Posts: 4
Joined: Wed Sep 22, 2010 11:22 am

Re: Alternate images instead of bullets/numbers in a list

Post by aurerua »

Great! Thanks a lot!

I will try that tomorrow as soon as I am on my own computer... :D
aurerua
Posts: 4
Joined: Wed Sep 22, 2010 11:22 am

Alternate images instead of bullets/numbers in a list

Post by aurerua »

I have tried it :)

It works well. I now have a little problem: because I would like to resize the image at the same time I have tried:

Code: Select all

\newcommand*{\Myitem}{% 
 \item[\protect\includegraphics[width=.6cm]{image\intcalcMod{\value{enumi}}{8}.jpg}]\stepcounter{enumi}% 
}
which creates an error. I think it comes from the nested []s, doesn't it? Is there a way to solve this kind of issue?

Thanks again!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Alternate images instead of bullets/numbers in a list

Post by gmedina »

aurerua wrote:I have tried it :)
...I think it comes from the nested []s, doesn't it? Is there a way to solve this kind of issue?..
Yes, and yes. Enclose the \includegraphics command using an extra pair of curly braces:

Code: Select all

\newcommand*{\Myitem}{% 
 \item[{\includegraphics[width=.6cm]{image\intcalcMod{\value{enumi}}{8}.jpg}}]\stepcounter{enumi}% 
}
aurerua wrote:...Thanks again!
You're welcome.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Teradil
Posts: 1
Joined: Tue Feb 01, 2011 8:19 am

Re: Alternate images instead of bullets/numbers in a list

Post by Teradil »

First of all I'd like to thank you, this thread has already helped me a lot.

But still I do have one problem, the images I use as replacement for the bullets are larger than my text. So the following paragraph is aligned at the bottom of the bullet which looks rather clumsy.

Is there a way to fix this?
Post Reply