图形路径和变量的问题

图形路径和变量的问题

\graphicspath我正在尝试使用如下例所示的变量来设置:

\documentclass[a4paper]{article}
\usepackage{graphicx}

\def\mypath{./LAG/DET}

\begin{document}
    \graphicspath{{\mypath/}}
%   \graphicspath{{./LAG/DET/}}
    \includegraphics[width=\textwidth]{DET001lsg}
\end{document}

这不起作用。Latex 失败并显示LaTeX Error: File 'DET001lsg' not found.消息。如果我直接设置路径,例如

\documentclass[a4paper]{article}
\usepackage{graphicx}

\def\mypath{./LAG/DET}

\begin{document}
%    \graphicspath{{\mypath/}}
    \graphicspath{{./LAG/DET/}}
    \includegraphics[width=\textwidth]{DET001lsg}
\end{document}

它突然起作用了。

这是为什么?我正在使用 TeXLive(版本:2023.20230613-3)

以下是日志终端输出:

pdflatex -file-line-error -interaction=nonstopmode -synctex=1 -output-format=pdf -output-directory=/home/tobias/tmp/serie1 text.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/home/tobias/tmp/serie1/text.tex
LaTeX2e <2023-06-01>
L3 programming layer <2023-06-05>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
(/home/tobias/tmp/serie1/text.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))

/home/tobias/tmp/serie1/text.tex:9: LaTeX Error: File `DET001lsg' not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.9 ...ncludegraphics[width=\textwidth]{DET001lsg}
                                                  
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
(/home/tobias/tmp/serie1/text.aux) )
(see the transcript file for additional information)</usr/share/texlive/texmf-d
ist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on /home/tobias/tmp/serie1/text.pdf (1 page, 9015 bytes).
SyncTeX written on /home/tobias/tmp/serie1/text.synctex.gz.
Transcript written on /home/tobias/tmp/serie1/text.log.

Process finished with exit code 1

和日志文件:

This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex 2024.1.5)  5 JAN 2024 09:13
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**text.tex
(./text.tex
LaTeX2e <2023-06-01>
L3 programming layer <2023-06-05>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2022/03/10 v1.4e Standard LaTeX Graphics (DPC,SPQR)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 107.

(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2022/09/22 v1.2b Graphics/color driver for pdftex
))
\Gin@req@height=\dimen141
\Gin@req@width=\dimen142
)
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2023-04-19 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count193
\l__pdf_internal_box=\box51
)
(./text.aux)
\openout1 = `text.aux'.

相关内容