
\includegraphics{}
포함된 파일의 이름(경로 및 확장명 포함)을 텍스트 파일에 쓰도록 명령을 수정하려고 합니다 . 내가 지금까지 가지고 있는 것은 다음과 같습니다.
\makeatletter
\newwrite\myfile
\immediate\openout\myfile=myfigures.txt
\let\TempCmd\Ginclude@graphics
\renewcommand{\Ginclude@graphics}[1]{\TempCmd{#1}\immediate\write\myfile{#1}}
\makeatother
이것의 유일한 문제는 파일 확장자가 지정되지 않으면 기록되지 않는다는 것입니다. 예를 들어, mypic.eps
라는 하위 폴더에 이라는 이름이 있는 경우 figures
, 내가 원하는 내용을 작성하려는 \includegraphics{figures/mypic}
경우 myfigures.txt
에만 해당 폴더에 작성하게 됩니다 .figures/mypic
figures/mypic.eps
나는 graphicx.sty와 snapshot.sty에서 파일 이름 확장자를 처리하는 방법을 알아낼 수 있는지 알아보고 직접 무언가를 해킹하려고 시도했지만 아직 알아낼 수 없었습니다. \filename@parse{#1}
거기에 넣으면 \filename@ext
.
다음은 최소한의 작업 예입니다(원하는 이미지를 제공하세요).
\documentclass{article}
\usepackage{graphicx}
\makeatletter
\newwrite\myfile
\immediate\openout\myfile=myfigures.txt
\let\TempCmd\Ginclude@graphics
\renewcommand{\Ginclude@graphics}[1]{\TempCmd{#1}\immediate\write\myfile{#1}}
\makeatother
\begin{document}
\includegraphics{mypic}
\end{document}
답변1
graphics
이미 다양한 확장을 시도하고 있으며 선택한 백엔드에 따라 어떤 파일을 사용할지 결정하므로 최상위 명령이 아닌 실제로 파일을 포함하기 위해 백엔드를 호출하기 직전에 거기에 연결하려고 합니다.
\documentclass{article}
\usepackage{graphicx}
\makeatletter
\newwrite\myfile
\immediate\openout\myfile=myfigures.txt
\let\TempCmd\Gin@setfile
\def\Gin@setfile#1#2#3{\TempCmd{#1}{#2}{#3}\immediate\write\myfile{#3}}
\makeatother
\begin{document}
\includegraphics{mypic}
\end{document}
생산하다
mypic.png