65

I often saw that MWEs which include images can be a little bit of a problem. There are no common images in the TEXMF tree which could be used. Even the famous PS tiger is not directly accessible. Often people add the demo option to graphicx to avoid the need of real images. Other times a \rule{<width>}{<height>} is added as a substitution. The problem with both is that you have to always tell users that the have to remove the option or replace the substituted code.

Therefore I now created a special CTAN package mwe which comes with a variety if dummy images which can be used for MWEs. They are installed in the CTAN package directly and therefore direct accessible through the TEXMF tree. In other words, if all people have installed this package they can share code like \includegraphics{example-image} and get an example image in their MWE with no extra effort. Even if users do not have the package installed the name makes it clear enough that they simply have to add a real image name.

There is also a mwe LaTeX package provided which load graphicx and both lipsum and blindtext. It may grow in the future but I like to keep it small in order to keep the used code in MWEs really minimal. The package is not required to be loaded in order to use the images. I see it only as a small bonus.

There are multiple images (all in the form example-image* in PDF, JPG, PNG and EPS format as well as TeX file holding its TikZ code). Originally they were all standalone files, but to keep things simple I stripped the preamble and document environment in my release script. These formats allow for specific MWEs were the file type is used or even matters. Also the different files allow to differ between multiple images in a figure with sub-figures etc. There are also PDF files for A4, letter, etc. for MWEs related to pdfpages and similar things.

Also, there are basically two types of MWEs: question MWEs and answer MWEs. The first one should show the issue / the code used, while the second form is mostly an example how to apply certain techniques. In both cases the images are useful. The package might not be wanted for the first kind and only for the second for certain example usages. Of course if there is a MWEs provided with a question, then it should be used as base of the answer code.


Here a small MWE to see how the whole thing works:

% Example MWE
\documentclass{article}
\usepackage{mwe}
\begin{document}

\blindtext

\noindent
\includegraphics[width=.4\textwidth]{example-image-a}\hfill
\includegraphics[width=.4\textwidth]{example-image-b}

\blindtext

\end{document}

Result

The images come from the TEXMF tree:

<example-image-a.png, id=1, 401.5pt x 301.125pt> <use example-image-a.png>
<example-image-b.png, id=2, 401.5pt x 301.125pt> <use example-image-b.png>
[1{/usr/local/texlive/2011/texmf-var/fonts/map/pdftex/updmap/pdftex.map} </usr/
local/texlive/2011/texmf-dist/tex/latex/mwe/example-image-a.png> </usr/local/te
xlive/2011/texmf-dist/tex/latex/mwe/example-image-b.png>]
  • 17
    One for the community blog? – Joseph Wright May 9 '12 at 19:58
  • @JosephWright: Indeed, I already talking with Paulo about it earlier. – Martin Scharrer May 9 '12 at 20:01
  • 4
    Thank you very much for this package. I often thought about sending some images to CTAN to use it in MWE, but never did it actually :-) – Tobi May 9 '12 at 22:35
  • @MartinScharrer: Would you consider adding \pagestyle{empty} to the package code? (If it's not yet included, of course...) – krlmlr May 15 '12 at 13:48
  • 1
    @user946850: I try to keep the code as minimal as possible to allow for a wide variety of examples. If you want a minimal PDF as a result you might simply use the standalone class. – Martin Scharrer May 15 '12 at 15:09
  • I think an example .bib-file would be a good addition to the mwe package, too. One or two articles, a book and an incollection for more complicated examples would probably be sufficient. – dhst Jun 1 '12 at 11:44
  • 1
    @dhst: You could open an enhancement request for mwe under bitbucket.org/martin_scharrer/mwe/issues/new. This way I have a list of requests which reminds me to do it. – Martin Scharrer Jun 1 '12 at 18:34
  • 1
    @dhst If you have biblatex installed, you can find an example bibfile named biblatex-examples.bib in your TEXMF tree. tex.stackexchange.com/questions/16490/… – matth Jun 11 '12 at 13:39
  • The size of original mwe.pdf is about 302 KB. After compressing it with gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=mwe-compressed.pdf mwe.pdf, it becomes 143 KB. Is it worth compressing all package manuals before uploading them to CTAN? – kiss my armpit Jul 25 '12 at 18:59
  • I think mwe.pdf should be put in the same directory in which the example-image-*s exist. Why? Because we can use it as \includegraphics[page=1]{mwe}, \includepdf[pages={1-last}]{mwe}, etc. – kiss my armpit Jul 28 '12 at 18:34
  • I don't think there is "an answer" for this question. Should it be closed? Retagged with status-completed? – Werner Jan 23 '13 at 22:10
  • @MartinScharrer: FWIW, context includes three sample images: cow.pdf, mill.png, and hacker.jpg. They are also accessible from LaTeX and can be used for minimal examples :) – Aditya Feb 3 '13 at 12:15

You must log in to answer this question.

Browse other questions tagged .