[twg-tds] Question: how to include an image file in a document class?

Lei Ye lei at uow.edu.au
Wed Sep 16 07:29:11 CEST 2015


Hi, Reinhard,

It's well explained. That's something I will keep in mind when I write with LateX from now on.

Thank you.
Lei



> On 16 Sep 2015, at 6:52 am, Reinhard Kotucha <reinhard.kotucha at web.de> wrote:
> 
>> On 2015-09-14 at 04:07:14 +0000, Lei Ye wrote:
>> 
>> It's my first time to know \graphicspath is deprecated.
>> 
>> In the following scenario, what is the best way to do it.
> 
> In the scenario you describe below it doesn't matter because you have
> only one directory.
> 
> TeX maintains a so-called string pool which contains error messages,
> control sequence names, file names, and maybe other things.  The size
> if the string pool is limited.  Unfortunately whatever goes to it will
> never be removed, hence it is steadily growing.
> 
> Consider the following code:
> 
>  \def\mymacro{}
>  \let\mymacro\undefined
> 
> Though \mymacro isn't accessible anymore, its name remains in the
> string pool forever.
> 
> Let's assume that you defined
> 
>  \graphicspath{{dir1/}{dir2/}{dir3/}}
> 
> and there is a file "dir3/IMG1234.JPEG".
> 
> If you write
> 
>  \includegraphics{IMG1234}
> 
> (without specifying an extension) and if we assume that pdftex looks for
> extensions
> 
>  .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2
> 
> in this order, it will check whether one if these files exist:
> 
>  dir1/IMG1234.png
>  dir1/IMG1234.pdf
>  dir1/IMG1234.jpg
>  dir1/IMG1234.mps
>  dir1/IMG1234.jpeg
>  dir1/IMG1234.jbig2
>  dir1/IMG1234.jb2
>  dir1/IMG1234.PNG
>  dir1/IMG1234.PDF
>  dir1/IMG1234.JPG
>  dir1/IMG1234.JPEG
>  dir1/IMG1234.JBIG2
>  dir1/IMG1234.JB2
>  dir2/IMG1234.png
>  dir2/IMG1234.pdf
>  dir2/IMG1234.jpg
>  dir2/IMG1234.mps
>  dir2/IMG1234.jpeg
>  dir2/IMG1234.jbig2
>  dir2/IMG1234.jb2
>  dir2/IMG1234.PNG
>  dir2/IMG1234.PDF
>  dir2/IMG1234.JPG
>  dir2/IMG1234.JPEG
>  dir2/IMG1234.JBIG2
>  dir2/IMG1234.JB2
>  dir3/IMG1234.png
>  dir3/IMG1234.pdf
>  dir3/IMG1234.jpg
>  dir3/IMG1234.mps
>  dir3/IMG1234.jpeg
>  dir3/IMG1234.jbig2
>  dir3/IMG1234.jb2
>  dir3/IMG1234.PNG
>  dir3/IMG1234.PDF
>  dir3/IMG1234.JPG
>  dir3/IMG1234.JPEG % <==
>  dir3/IMG1234.JBIG2
>  dir3/IMG1234.JB2
> 
> TeX stops searching when dir3/IMG1234.JPEG is found but all file
> names it checked before also remain in the string pool forever.
> 
> This has two consequences:
> 
>   1. Though the pool size is quite large nowadays, it's still
>      limited.  No problem with the example above but some packages
>      add a lot of stuff to the string pool too wich might lead to the
>      famous error message "Capacity exceeded".
> 
>   2. If the string pool is large, TeX needs a lot of time in order to
>      find control sequences.  Fortunately the string pool is actually
>      a hash table and thus time consumption grows logarithmically.
>      But a huge string pool slows down TeX significantly though.
> 
> Whether this is problematic depends on the number of strings which
> actually are in the pool.  A few directory names usually don't cause
> trouble but some macros generate control sequence names on the fly.
> 
> I already had to increase the string pool in order to create many
> plots using the pgfplots package.  But the impact on processing time
> remained, of course.
> 
>> I first have a subfolder call images/ to hold my figures and have
>> 100
>> 
>> \includegraphics{images/myimage.png}
>> 
>> Then later I decide to change the hosting folder to
>> figures/. Instead of replacing "images/" in all 100
>> \includegraphics commands, what is a better way to do it?
> 
> Well, what would you do if you write a program and decide later to
> change names of variables and/or functions?  I think that every
> reasonable text editor is sufficient.
> 
> Furthermore, if you state the directory explicitly in the
> \includegraphics argument you don't have to search the file yourself
> whenever you want to replace it.
> 
> Regards,
>  Reinhard
> 
> -- 
> ------------------------------------------------------------------
> Reinhard Kotucha                            Phone: +49-511-3373112
> Marschnerstr. 25
> D-30167 Hannover                    mailto:reinhard.kotucha at web.de
> ------------------------------------------------------------------



More information about the twg-tds mailing list