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}
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>]
\pagestyle{empty}
to the package code? (If it's not yet included, of course...)standalone
class..bib
-file would be a good addition to themwe
package, too. One or twoarticles
, abook
and anincollection
for more complicated examples would probably be sufficient.mwe
under bitbucket.org/martin_scharrer/mwe/issues/new. This way I have a list of requests which reminds me to do it.mwe.pdf
is about 302 KB. After compressing it withgswin64c -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?mwe.pdf
should be put in the same directory in which theexample-image-*
s exist. Why? Because we can use it as\includegraphics[page=1]{mwe}
,\includepdf[pages={1-last}]{mwe}
, etc.cow.pdf
,mill.png
, andhacker.jpg
. They are also accessible from LaTeX and can be used for minimal examples :)