I would like to generate a document including several images. Under each image should be a different caption, taken from an text file, separated by line or semicolon.

For example:

imagename: 1.jpg

text file line 1: Description 1

Results to an image with caption placed in the document.

Furthermore I would like it arranged, about 4-6 images per page.

  • 2
    Where in all of this goes in automation? I think you should clarify this. Also, automation is much easier via the help of the OS, so use BAT or shell scripts depending on Windows or unix-like systems, respectively. – zeroth Oct 18 '15 at 20:58
  • 1
    See for example (not only my answer, of course) to this question here: tex.stackexchange.com/questions/256859/… – user31729 Oct 18 '15 at 21:00
  • 1
    Without a minimal document, we have no clue what your set up is and can only guess what might work or not. If the names of the images were also in the other file, for example, you could pull them in with their captions in order. Arranging them, though, would depend on your class and page layout (obviously). – cfr Oct 18 '15 at 21:22
  • I would like to add a hugh number of images to an latex document. Let's assume I already sorted them and have text file that includes a description for the image. Lets say, picture00.jpg presents and apple, first line in the text file would be "This is a nice example for an apple", picture01.jpg shows a banana, second line in the text would be "This picture shows a banana" and so on. Each sentence is different! – schwabenchris Oct 23 '15 at 17:52

I’d create a macro for inserting images and call it with as few arguments as possible. If you are dealing with a very large amount of images, you might want to look in to automating the creation of the .tex file, for adding macro command calls.

My code assumes images image-1.png, image-2.jpg and image-3.jpg are in the same directory as the .tex file.




Mauris a sapien fringilla, interdum sapien non, dapibus erat.

\image{image-1}{Description 1} % this is one of the lines that could be automatically generated

Quisque dolor mauris, molestie ut convallis sit amet pharetra.

\image{image-2}{Description 2} % this is one of the lines that could be automatically generated

Pellentesque porttitor eleifend porta. Duis tincidunt purus felis.

\image{image-3}{Description 3} % this is one of the lines that could be automatically generated

Suspendisse blandit pretium tempus. Vestibulum vitae lacus sed.

|improve this answer|||||
  • You assume that the caption is the same as the name of the image. So \image should have two different arguments. – jarauh Oct 19 '15 at 1:39
  • You’re right. Answer updated! – gnucchi Oct 19 '15 at 13:10

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.