如何直接导入更好的 MWE 示例图像

如何直接导入更好的 MWE 示例图像

为了在此网站上询问与图像相关的问题,我知道我可以按以下方式直接调用基本的非描述性图像:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\includegraphics[width=2cm]{example-image}\\
%\fbox{\includegraphics[trim=1 150 0 0,scale=0.1]{tiger}}
\end{document}

产生

在此处输入图片描述

然而,在某些情况下,实际图片

在此处输入图片描述

会更加理想。

我知道上面的老虎可以用命令来制作

\fbox{\includegraphics[trim=1 150 0 0,scale=0.1]{tiger}}

但好像这个tiger图像不能被包调用graphicx

老虎图像以及其他类似图像是否可以通过调用某些包直接使用?我想我可以将这个经常出现在这个网站上的图像保存到我的电脑中,然后以这种方式调用它,但是,回答我发布的问题的人将无法无错误地运行我的 MWE。

问题:为了在此网站上提问,将 Latex 老虎(和类似类型的图像)纳入 MWE 的最简单方法是什么?

谢谢。

答案1

老虎是一个 ghostscript 测试 eps 文件,不是来自 latex 分布,也不在默认输入树中。

有一些图像是 ,并且会从 进行更改example-image,例如\includegraphics{pink_marble}\includegraphics{mill}。最后一个来自上下文,但 latex 会找到它。

texlive 输入树中 png 文件的完整列表是

 for i in $(grep '\.png' $(kpsewhich --all ls-R) | sed -e 's/.*://' | sort | uniq ); do kpsewhich $i; done

显示的内容如下,显然您可以对 jpg 或 eps 执行类似操作。

/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_FOM_background.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_FOM_frametitlebackground.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_FOM_ifes_backgound.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_FOM_ifes_frametitlebackgound.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_FOM_ifes_logo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_SC_logo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_eufom_backgound.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_eufom_frametitlebackgound.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_eufom_linie.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/NPBT_eufom_logo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/uowthesis/UoWlogo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/alertmessage/img/alertmessage-error.png
/usr/local/texlive/2021/texmf-dist/tex/latex/alertmessage/img/alertmessage-info.png
/usr/local/texlive/2021/texmf-dist/tex/latex/alertmessage/img/alertmessage-success.png
/usr/local/texlive/2021/texmf-dist/tex/latex/alertmessage/img/alertmessage-warning.png
/usr/local/texlive/2021/texmf-dist/tex/latex/tcolorbox/blueshade.png
/usr/local/texlive/2021/texmf-dist/tex/latex/stex/mikoslides/cc-by-sa.png
/usr/local/texlive/2021/texmf-dist/tex/latex/stex/mikoslides/cc_somerights.png
/usr/local/texlive/2021/texmf-dist/tex/context/base/context-version.png
/usr/local/texlive/2021/texmf-dist/tex/latex/tcolorbox/crinklepaper.png
/usr/local/texlive/2021/texmf-dist/tex/latex/stex/mikoslides/dangerous-bend.png
/usr/local/texlive/2021/texmf-dist/tex/latex/iodhbwm/dhbw-logo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/elpres/ep-ball-01.png
/usr/local/texlive/2021/texmf-dist/tex/latex/elpres/ep-ball-02.png
/usr/local/texlive/2021/texmf-dist/tex/latex/elpres/ep-ball-03.png
/usr/local/texlive/2021/texmf-dist/tex/latex/elpres/ep-ball-04.png
/usr/local/texlive/2021/texmf-dist/tex/latex/elpres/ep-ball-05.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-grid-100x100bp.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-grid-100x100pt.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-10x16.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-16x10.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-16x9.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-1x1.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-4x3.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-9x16.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-a.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-b.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image-c.png
/usr/local/texlive/2021/texmf-dist/tex/latex/mwe/example-image.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_acid-8.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_acid.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_aqpol.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_bottle-2-black.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_bottle-2-white.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_bottle.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_exclam.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos-1.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos-2.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos-3.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos-4.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos-5.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos-6.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_explos.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-2-black.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-2-white.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-3-black.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-3-white.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-4-1.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-4-2.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-4-3-black.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-4-3-white.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-5-2-black.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-5-2-white.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-O-5-1.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame-O.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_flame.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_health.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_skull-2.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_skull-6.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ghsystem/pictures/ghsystem_skull.png
/usr/local/texlive/2021/texmf-dist/tex/latex/tcolorbox/goldshade.png
/usr/local/texlive/2021/texmf-dist/tex/latex/notes/hand.png
/usr/local/texlive/2021/texmf-dist/tex/latex/ijsra/ijsra_logo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/notes/info.png
/usr/local/texlive/2021/texmf-dist/tex/latex/stex/mikoslides/jacobs-logo.png
/usr/local/texlive/2021/texmf-dist/tex/latex/beamertheme-npbt/images/lNPBT_SC_linie.png
/usr/local/texlive/2021/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png
/usr/local/texlive/2021/texmf-dist/tex/context/sample/common/mill.png
/usr/local/texlive/2021/texmf-dist/tex/optex/demo/op-ring.png
/usr/local/texlive/2021/texmf-dist/tex/optex/demo/op-slides-bg.png
/usr/local/texlive/2021/texmf-dist/tex/latex/tcolorbox/pink_marble.png
/usr/local/texlive/2021/texmf-dist/tex/latex/stex/mikoslides/shading-l2r.png
/usr/local/texlive/2021/texmf-dist/tex/latex/sillypage/sillywalk-map.png
/usr/local/texlive/2021/texmf-dist/tex/latex/notes/warn.png

最后是一个完整的例子:

在此处输入图片描述

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\includegraphics[width=5cm]{mill}

\end{document}

答案2

图片中包含的内容不应该影响你处理解决方案的方式。你绝对可以表述问题并使用来自的示例图片mwe. 这就是所提供的美mwe(从其文档

一旦安装在 TEXMF 树中的正确目录中,它们将可用于所有文档。这样,用户可以编译其他人提供给他的使用这些图像文件的任何 MWE,而无需替换代码或共享图像。

如果您认为图像单调且需要更多颜色,请使用pagefromexample-image-a4-numberedexample-image-letter-numbered

\includegraphics[page=10]{example-image-letter-numbered]

在此处输入图片描述

还有example-grid-100x100ptexample-grid-100x100bp

在此处输入图片描述

如果您想要包含“示例文档”(寻找更多文本),则有example-image-letterexample-image-letter-landscape(以及其他尺寸,如a3a4a5)。

在我看来,mwe包装元素可能是最常用但最少被提及的元素之一(在这个网站上),因为你不必\usepackage{mwe}为了使用图像而使用它。

作为参考,该tiger图像可在某些包位置中找到。例如,tiger.pdfyathesistiger.pdftkz-base。因此,这些存在于 TeX 目录结构 (TDS) 中,但您必须更改\graphicspath,或直接引用它们 ( \includegraphics[..]{path/to/image/tiger})。

简而言之,使用“更理想”的图像并不能使问题变得更好。您应该能够以不需要任何特定图像(不包含在/分发给mwe)的方式提出问题。

答案3

如果您想要一个不那么无聊的图像,您可以使用该tikzlings包,例如:

\documentclass{article}
\usepackage{tikzlings}
\begin{document}
\tikz{\sloth}
\end{document}

在此处输入图片描述

但里面没有老虎tikzlings

对于 tiger,可以使用.eps来包含文件的原始源代码filecontents。这里只给出大纲,以使代码更简短:

\begin{filecontents*}{tiger.eps}
%!PS-Adobe-2.0 EPSF-1.2
%%BoundingBox: 1 150 611 792
/InitDictCount countdictstack def
gsave
save
mark
newpath
/showpage {} def
%!PS-Adobe-2.0 EPSF-1.2
%%Creator: Adobe Illustrator(TM) 1.2d4
%%For: OpenWindows Version 2
%%Title: tiger.eps
%%CreationDate: 4/12/90 3:20 AM
%%DocumentProcSets: Adobe_Illustrator_1.2d1 0 0
%%DocumentSuppliedProcSets: Adobe_Illustrator_1.2d1 0 0
%%BoundingBox: 22 171 567 738
%%EndComments

%%BeginProcSet:Adobe_Illustrator_1.2d1 0 0

/Adobe_Illustrator_1.2d1 dup 100 dict def load begin
% definition operators
/bdef {bind def} bind def
/ldef {load def} bdef
/xdef {exch def} bdef
% graphic state operators
/_K { 3 index add neg dup 0 lt {pop 0} if 3 1 roll } bdef
/_k /setcmybcolor where {
    /setcmybcolor get
} {
    { 1 sub 4 1 roll _K _K _K setrgbcolor pop } bind
} ifelse def
/g {/_b xdef /p {_b setgray} def} bdef
/G {/_B xdef /P {_B setgray} def} bdef
/k {/_b xdef /_y xdef /_m xdef /_c xdef /p {_c _m _y _b _k} def} bdef
/K {/_B xdef /_Y xdef /_M xdef /_C xdef /P {_C _M _Y _B _k} def} bdef
/d /setdash ldef
/_i currentflat def
/i {dup 0 eq {pop _i} if setflat} bdef
/j /setlinejoin ldef
/J /setlinecap ldef
/M /setmiterlimit ldef
/w /setlinewidth ldef
% path construction operators
/_R {.25 sub round .25 add} bdef
/_r {transform _R exch _R exch itransform} bdef
/c {_r curveto} bdef
/C /c ldef
/v {currentpoint 6 2 roll _r curveto} bdef
/V /v ldef
/y {_r 2 copy curveto} bdef
/Y /y ldef
/l {_r lineto} bdef
/L /l ldef
/m {_r moveto} bdef
% path painting operators
/n /newpath ldef
/N /n ldef
/F {p fill} bdef
/f {closepath F} bdef
/S {P stroke} bdef
/s {closepath S} bdef
/B {gsave F grestore S} bdef
/b {closepath B} bdef
end
%%EndProcSet
%%EndProlog

%%Page: 1 1

Adobe_Illustrator_1.2d1 begin

.8 setgray
%clippath fill
-110 -300 translate
1.1 dup scale

0 g
0 G
0 i
0 J
0 j
0.172 w
10 M
[]0 d
0 0 0 0 k

177.696 715.715 m
177.797 713.821 176.973 713.84 v
176.149 713.859 159.695 761.934 139.167 759.691 C
156.95 767.044 177.696 715.715 V
b
181.226 718.738 m
180.677 716.922 179.908 717.221 v
179.14 717.519 180.023 768.325 159.957 773.199 C
179.18 774.063 181.226 718.738 V
b
208.716 676.41 m
210.352 675.45 209.882 674.773 v
209.411 674.096 160.237 686.898 150.782 668.541 C
154.461 687.428 208.716 676.41 V
b
205.907 666.199 m
207.763 665.803 207.529 665.012 v
207.296 664.221 156.593 660.879 153.403 640.478 C
150.945 659.563 205.907 666.199 V
b
201.696 671.724 m
203.474 671.061 203.128 670.313 v
202.782 669.565 152.134 673.654 146.002 653.936 C
146.354 673.175 201.696 671.724 V
b
190.991 689.928 m
192.299 688.554 191.66 688.033 v
191.021 687.512 147.278 713.366 133.131 698.324 C
141.872 715.467 190.991 689.928 V
b
183.446 685.737 m
184.902 684.52 184.326 683.929 v
183.75 683.339 137.362 704.078 125.008 687.531 C
131.753 705.553 183.446 685.737 V
b
180.846 681.665 m
182.454 680.657 181.964 679.994 v
181.474 679.331 132.692 693.554 122.709 675.478 C
126.934 694.251 180.846 681.665 V
b
191.58 681.051 m
192.702 679.52 192.001 679.085 v
191.3 678.65 151.231 709.898 135.273 696.793 C
146.138 712.674 191.58 681.051 V
b
171.8 710 m
172.4 708.2 171.6 708 v
170.8 707.8 142.2 749.8 122.999 742.2 C
138.2 754 171.8 710 V
b
172.495 703.021 m
173.47 701.392 172.731 701.025 v
171.993 700.657 135.008 735.501 117.899 723.939 C
130.196 738.739 172.495 703.021 V
b
172.38 698.651 m
173.502 697.12 172.801 696.685 v
172.1 696.251 132.031 727.498 116.073 714.393 C
126.938 730.274 172.38 698.651 V
b
0 J 1 w
170.17 696.935 m
170.673 690.887 171.661 684.318 173.4 681.199 C
169.8 668.799 178.6 655.599 V
178.2 648.399 179.8 645.199 V
183.8 636.799 188.6 635.999 v
192.484 635.352 201.207 632.283 211.068 630.879 c
228.2 616.799 225 603.999 V
224.6 587.599 221 585.999 V
232.6 597.199 223 580.399 V
218.6 561.599 l
244.2 583.199 228.6 564.799 V
218.6 538.799 l
238.2 557.199 231 548.799 V
227.8 539.999 l
271 567.199 240.2 537.599 V
248.2 541.199 252.6 538.399 V
259.4 539.599 258.6 537.999 V
237.8 527.599 234.2 509.199 V
242.6 519.199 239.4 508.399 V
239.8 496.799 l
243.8 518.399 243.4 480.799 V
262.6 498.799 251 477.999 V
251 461.199 l
266.2 477.599 259.8 464.799 V
269.8 473.599 265.8 458.399 V
265 447.999 269.4 459.199 V
285.4 489.799 279.4 463.599 V
278.6 444.399 283.4 459.199 V
283.8 448.799 293 441.599 V
291.8 492.399 304.6 456.399 V
308.6 439.999 l
311.4 449.199 311 454.399 V
325.8 470.799 319 446.399 V
334.2 469.199 331 455.999 V
323.4 439.999 325 435.199 V
341.8 469.999 343 471.599 V
341 429.198 351.8 465.199 V
357.4 453.199 354.6 448.799 V
362.6 456.799 361.8 459.999 V
366.4 468.199 369.2 454.599 V
371 445.199 372.6 448.399 V
376.6 424.398 377.8 447.199 V
379.4 460.799 372.2 472.399 V
373 475.599 370.2 479.599 v
383.8 457.999 376.6 486.799 V
387.801 478.799 389.001 478.799 V
375.4 501.999 384.2 497.199 V
379 507.599 397.001 495.599 V
381 511.599 398.601 501.999 V
406.601 495.599 399.001 505.599 V
384.6 521.599 406.601 503.599 V
418.201 487.199 419.001 484.399 V
409.001 513.599 404.601 516.399 V
413.001 552.799 454.201 537.199 V
461.001 519.999 465.401 538.399 V
478.201 544.799 489.401 517.199 V
493.401 530.799 492.601 533.599 V
499.401 532.399 498.601 533.599 V
511.801 529.199 513.001 529.999 V
519.801 523.199 520.201 526.799 V
529.401 523.999 527.401 527.599 V
536.201 511.999 536.601 508.399 V
539.001 522.399 l
541.001 519.599 l
542.601 527.199 541.801 528.399 v
541.001 529.599 561.801 521.599 566.601 500.799 C
568.601 492.399 l
574.601 507.199 573.001 511.199 V
578.201 510.399 578.601 505.999 V
582.601 529.199 577.801 535.199 V
582.201 535.999 583.401 532.399 V
583.401 539.599 l
590.601 538.799 590.601 541.199 V
595.001 545.199 597.001 540.399 V
584.601 575.599 603.001 556.399 V
610.201 545.599 606.601 564.399 v
603.001 583.199 599.001 584.799 603.801 585.199 C
604.601 588.799 602.601 590.399 v
600.601 591.999 603.801 590.399 y
608.601 586.399 603.401 608.399 V
609.801 606.799 597.801 635.999 V
600.601 638.399 596.601 646.799 V
604.601 642.399 607.401 643.999 V
607.001 645.599 603.801 649.599 V
582.201 704.4 602.601 682.399 V
614.451 668.849 608.051 691.649 V
598.94 715.659 599.717 719.955 V
170.17 696.935 l
b
0.2 0.55 0.85 0 k
599.717 719.755 m
600.345 719.574 602.551 718.45 603.801 716.8 C
610.601 706 605.401 724.4 V
596.201 753.2 605.001 742 V
611.001 734.8 607.801 748.4 v
603.936 764.827 601.401 771.2 y
613.001 766.4 586.201 806 V
595.001 802.4 l
575.401 842 553.801 847.2 V
545.801 853.2 l
584.201 891.2 571.401 928 V
564.601 933.2 555.001 924 V
548.601 919.2 542.601 920.8 V
511.801 919.6 509.801 919.6 v
507.801 919.6 473.001 956.8 407.401 939.2 C
402.201 937.2 397.801 938.4 V
379.4 954.4 330.6 931.6 v
320.6 929.6 319 929.6 v
317.4 929.6 314.6 929.6 306.6 923.2 c
298.6 916.8 298.2 916 296.2 914.4 C
279.8 903.2 275 902.4 V
263.4 896 259 886 V
255.4 884.8 l
253.8 877.6 253.4 876.4 V
248.6 872.8 247.8 867.2 V
239 861.2 239.4 856.8 V
237.8 851.6 237 846.8 V
229.8 842 230.6 839.2 V
223 825.2 224.2 818.4 V
217.8 818.8 215 816.4 V
214.2 811.6 212.6 811.2 V
209.8 810 212.2 806 V
210.6 803.2 210.2 801.6 V
211 798.8 206.6 793.2 V
200.2 774.4 202.2 769.2 V
202.6 764.4 199.8 762.8 V
196.2 763.2 204.6 751.2 V
205.4 750 202.2 747.6 V
185 744 182.6 727.6 V
169 712.8 169 707.6 v
169 705.295 169.271 702.148 169.97 697.535 C
169.4 689.199 197 688.399 v
224.6 687.599 599.717 719.755 Y
b
0 g
1 w
210.75 631 m
232.75 626.25 l
S
261 469 m
260.5 472.5 251.5 462 v
S
266.5 464 m
268.5 470.5 262 466 v
S
320.5 455.5 m
322 466.5 310.5 453.5 v
S

showpage

% Modification Denis GIROU (CNRS/IDRIS - France) <[email protected]> - 18 Dec. 1997
%% %%Trailer
countdictstack InitDictCount sub { end } repeat
cleartomark
restore
grestore
\end{filecontents*}
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\fbox{\includegraphics[width=5cm]{tiger}}
\end{document}

结果:

在此处输入图片描述

但对于 MWE 来说可能并不理想 :)

相关内容