无法使用子文件和 XeLaTeX 加载图片或 PDF 文件

无法使用子文件和 XeLaTeX 加载图片或 PDF 文件

我正在尝试.pdf_tex使用文件将图表包含在 tex 文件中xelatex

main.tex

% Preamble
\documentclass[10pt]{article}

% Packages
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{amsmath,amsthm}
\usepackage{amsfonts}
\usepackage{geometry}
\usepackage{multicol}
\usepackage{bookmark}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[multidot]{grffile}

% Do not use apacite and natlib at the same time
%\usepackage[numbers,sort&compress]{natbib} % Use for numbered reference
\usepackage[sort&compress]{natbib}
%\usepackage[natbibapa]{apacite}

% Section formatting
\usepackage{titlesec}
% Custom subsubsubsection
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother
% Uses alphabets instead of numbers for the subsubsubsection
\def\thesubsubsubsection{\alph{subsubsubsection}}


% Subfiles with biblio for multiple tex files
\usepackage{subfiles}
\providecommand{\main}{.}
\def\biblio{\bibliography{main}\bibliographystyle{apalike}}
\def\biblio{}

% Citation formatting !!! MUST BE LAST
\PassOptionsToPackage{hyphens,spaces}{url}
\usepackage{breakcites}
\usepackage{hyperref}

% Page Settings
\geometry{a4paper, margin = 1in}

% Document
\begin{document}


  \subfile{methodology/methodology.tex}


\end{document}

methodology.tex包含调用的文件.pdf_tex

% Preamble
\providecommand{\main}{..}
\documentclass[\main/main.tex]{subfiles}

% Packages

% Document
\begin{document}


  \begin{figure}
  \def\svgwidth{\linewidth}
  \input{\main/assets/images/xor_data_embedding.pdf_tex}
  \caption{Diagram}
  \end{figure}


\end{document}

希望得到这样的输出在此处输入图片描述可惜。

但我似乎不知道如何解决这个问题。它说无法加载文件,但我似乎不知道原因。

终端输出:

line 56: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=1]{xor_data_embedding.pdf}}
line 56: Package graphics Error: Division by 0. ...nitlength,page=1]{xor_data_embedding.pdf}}
line 56: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=1]{xor_data_embedding.pdf}}
line 58: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=2]{xor_data_embedding.pdf}}
line 58: Package graphics Error: Division by 0. ...nitlength,page=2]{xor_data_embedding.pdf}}
line 58: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=2]{xor_data_embedding.pdf}}
line 60: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=3]{xor_data_embedding.pdf}}
line 60: Package graphics Error: Division by 0. ...nitlength,page=3]{xor_data_embedding.pdf}}
line 60: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=3]{xor_data_embedding.pdf}}
line 62: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=4]{xor_data_embedding.pdf}}
line 62: Package graphics Error: Division by 0. ...nitlength,page=4]{xor_data_embedding.pdf}}
line 62: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=4]{xor_data_embedding.pdf}}
line 64: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=5]{xor_data_embedding.pdf}}
line 64: Package graphics Error: Division by 0. ...nitlength,page=5]{xor_data_embedding.pdf}}
line 64: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=5]{xor_data_embedding.pdf}}
line 66: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=6]{xor_data_embedding.pdf}}
line 66: Package graphics Error: Division by 0. ...nitlength,page=6]{xor_data_embedding.pdf}}
line 66: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=6]{xor_data_embedding.pdf}}
line 68: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=7]{xor_data_embedding.pdf}}
line 68: Package graphics Error: Division by 0. ...nitlength,page=7]{xor_data_embedding.pdf}}
line 68: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=7]{xor_data_embedding.pdf}}
line 70: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=8]{xor_data_embedding.pdf}}
line 70: Package graphics Error: Division by 0. ...nitlength,page=8]{xor_data_embedding.pdf}}
line 70: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=8]{xor_data_embedding.pdf}}
line 72: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=9]{xor_data_embedding.pdf}}
line 72: Package graphics Error: Division by 0. ...nitlength,page=9]{xor_data_embedding.pdf}}
line 72: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...nitlength,page=9]{xor_data_embedding.pdf}}
line 74: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=10]{xor_data_embedding.pdf}}
line 74: Package graphics Error: Division by 0. ...itlength,page=10]{xor_data_embedding.pdf}}
line 74: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=10]{xor_data_embedding.pdf}}
line 76: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=11]{xor_data_embedding.pdf}}
line 76: Package graphics Error: Division by 0. ...itlength,page=11]{xor_data_embedding.pdf}}
line 76: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=11]{xor_data_embedding.pdf}}
line 78: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=12]{xor_data_embedding.pdf}}
line 78: Package graphics Error: Division by 0. ...itlength,page=12]{xor_data_embedding.pdf}}
line 78: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=12]{xor_data_embedding.pdf}}
line 80: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=13]{xor_data_embedding.pdf}}
line 80: Package graphics Error: Division by 0. ...itlength,page=13]{xor_data_embedding.pdf}}
line 80: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=13]{xor_data_embedding.pdf}}
line 82: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=14]{xor_data_embedding.pdf}}
line 82: Package graphics Error: Division by 0. ...itlength,page=14]{xor_data_embedding.pdf}}
line 82: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=14]{xor_data_embedding.pdf}}
line 84: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=15]{xor_data_embedding.pdf}}
line 84: Package graphics Error: Division by 0. ...itlength,page=15]{xor_data_embedding.pdf}}
line 84: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=15]{xor_data_embedding.pdf}}
line 86: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=16]{xor_data_embedding.pdf}}
line 86: Package graphics Error: Division by 0. ...itlength,page=16]{xor_data_embedding.pdf}}
line 86: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=16]{xor_data_embedding.pdf}}
line 88: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=17]{xor_data_embedding.pdf}}
line 88: Package graphics Error: Division by 0. ...itlength,page=17]{xor_data_embedding.pdf}}
line 88: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=17]{xor_data_embedding.pdf}}
line 90: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=18]{xor_data_embedding.pdf}}
line 90: Package graphics Error: Division by 0. ...itlength,page=18]{xor_data_embedding.pdf}}
line 90: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=18]{xor_data_embedding.pdf}}
line 92: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=19]{xor_data_embedding.pdf}}
line 92: Package graphics Error: Division by 0. ...itlength,page=19]{xor_data_embedding.pdf}}
line 92: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=19]{xor_data_embedding.pdf}}
line 94: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=20]{xor_data_embedding.pdf}}
line 94: Package graphics Error: Division by 0. ...itlength,page=20]{xor_data_embedding.pdf}}
line 94: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=20]{xor_data_embedding.pdf}}
line 96: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=21]{xor_data_embedding.pdf}}
line 96: Package graphics Error: Division by 0. ...itlength,page=21]{xor_data_embedding.pdf}}
line 96: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=21]{xor_data_embedding.pdf}}
line 98: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=22]{xor_data_embedding.pdf}}
line 98: Package graphics Error: Division by 0. ...itlength,page=22]{xor_data_embedding.pdf}}
line 98: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...itlength,page=22]{xor_data_embedding.pdf}}
line 100: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=23]{xor_data_embedding.pdf}}
line 100: Package graphics Error: Division by 0. ...tlength,page=23]{xor_data_embedding.pdf}}
line 100: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=23]{xor_data_embedding.pdf}}
line 102: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=24]{xor_data_embedding.pdf}}
line 102: Package graphics Error: Division by 0. ...tlength,page=24]{xor_data_embedding.pdf}}
line 102: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=24]{xor_data_embedding.pdf}}
line 104: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=25]{xor_data_embedding.pdf}}
line 104: Package graphics Error: Division by 0. ...tlength,page=25]{xor_data_embedding.pdf}}
line 104: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=25]{xor_data_embedding.pdf}}
line 106: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=26]{xor_data_embedding.pdf}}
line 106: Package graphics Error: Division by 0. ...tlength,page=26]{xor_data_embedding.pdf}}
line 106: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=26]{xor_data_embedding.pdf}}
line 108: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=27]{xor_data_embedding.pdf}}
line 108: Package graphics Error: Division by 0. ...tlength,page=27]{xor_data_embedding.pdf}}
line 108: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=27]{xor_data_embedding.pdf}}
line 110: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=28]{xor_data_embedding.pdf}}
line 110: Package graphics Error: Division by 0. ...tlength,page=28]{xor_data_embedding.pdf}}
line 110: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=28]{xor_data_embedding.pdf}}
line 112: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=29]{xor_data_embedding.pdf}}
line 112: Package graphics Error: Division by 0. ...tlength,page=29]{xor_data_embedding.pdf}}
line 112: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=29]{xor_data_embedding.pdf}}
line 114: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=30]{xor_data_embedding.pdf}}
line 114: Package graphics Error: Division by 0. ...tlength,page=30]{xor_data_embedding.pdf}}
line 114: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=30]{xor_data_embedding.pdf}}
line 116: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=31]{xor_data_embedding.pdf}}
line 116: Package graphics Error: Division by 0. ...tlength,page=31]{xor_data_embedding.pdf}}
line 116: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=31]{xor_data_embedding.pdf}}
line 118: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=32]{xor_data_embedding.pdf}}
line 118: Package graphics Error: Division by 0. ...tlength,page=32]{xor_data_embedding.pdf}}
line 118: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=32]{xor_data_embedding.pdf}}
line 120: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=33]{xor_data_embedding.pdf}}
line 120: Package graphics Error: Division by 0. ...tlength,page=33]{xor_data_embedding.pdf}}
line 120: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=33]{xor_data_embedding.pdf}}
line 122: Unable to load picture or PDF file 'xor_data_embedding.pdf'. ...tlength,page=34]{xor_data_embedding.pdf}}
: inputenc package ignored with utf8 based engines.
: Rerun to get /PageLabels entry.
line 56: File `xor_data_embedding.pdf' not found
line 58: File `xor_data_embedding.pdf' not found
line 60: File `xor_data_embedding.pdf' not found
line 62: File `xor_data_embedding.pdf' not found
line 64: File `xor_data_embedding.pdf' not found
line 66: File `xor_data_embedding.pdf' not found
line 68: File `xor_data_embedding.pdf' not found
line 70: File `xor_data_embedding.pdf' not found
line 72: File `xor_data_embedding.pdf' not found
line 74: File `xor_data_embedding.pdf' not found
line 76: File `xor_data_embedding.pdf' not found
line 78: File `xor_data_embedding.pdf' not found
line 80: File `xor_data_embedding.pdf' not found
line 82: File `xor_data_embedding.pdf' not found
line 84: File `xor_data_embedding.pdf' not found
line 86: File `xor_data_embedding.pdf' not found
line 88: File `xor_data_embedding.pdf' not found
line 90: File `xor_data_embedding.pdf' not found
line 92: File `xor_data_embedding.pdf' not found
line 94: File `xor_data_embedding.pdf' not found
line 96: File `xor_data_embedding.pdf' not found
line 98: File `xor_data_embedding.pdf' not found
line 100: File `xor_data_embedding.pdf' not found
line 102: File `xor_data_embedding.pdf' not found
line 104: File `xor_data_embedding.pdf' not found
line 106: File `xor_data_embedding.pdf' not found
line 108: File `xor_data_embedding.pdf' not found
line 110: File `xor_data_embedding.pdf' not found
line 112: File `xor_data_embedding.pdf' not found
line 114: File `xor_data_embedding.pdf' not found
line 116: File `xor_data_embedding.pdf' not found
line 118: File `xor_data_embedding.pdf' not found
line 120: File `xor_data_embedding.pdf' not found
line 122: File `xor_data_embedding.pdf' not found

我认为我没有忘记将xor_data_embedding.*文件放入正确的文件夹中。

文件夹结构:

.
|
+---out
|       main.aux
|       main.bbl
|       main.blg
|       main.log
|       main.pdf
\---src
    |   main.tex
    +---assets
    |   \---images
    |           xor_data_embedding.pdf
    |           xor_data_embedding.pdf_tex
    \---methodology
            methodology.tex

该图表使用 Adob​​e Illustrator 制作,并导出到.svg,然后.pdf_tex使用 Inkscape 转换为 。文件为这里如果需要。

非常感谢任何指导。

答案1

为什么直接指定时找不到路径?

因为有两条不同的路径:(a)到xor_data_embedding.pdf从 看到的图像的路径main.tex,以及(b)到文件的路径 xor_data_embedding.pdf_tex

methodology.tex输入文件,该文件位于同一目录中,../assets/images/xor_data_embedding.pdf_tex可以顺利地生成图形作为输出。xor_data_embedding.pdf

有三种可能的情况需要测试:

(1)运行methodology.tex评论\subfile{methodology/methodology.tex}main.tex

它将methodology.pdf在其自己的目录中生成使用

.././assets/images//xor_data_embedding.pdf' 作为来源。

它不需要\graphicspath{{./assets/images/}}在主程序中。

(2)运行main.tex,现在包括\subfile{methodology/methodology.tex}

编译器将运行两次,但这与路径或子文件无关。

在图中添加\graphicspath{{./assets/images/}}点,它将在根目录中生成并用作 源。main.texmain.pdf./assets/images//xor_data_embedding.pdf

(3)运行methodology.tex,包括 \subfile{methodology/methodology.tex}在内main.tex,从根目录中删除除之外的所有文件main.tex

与以前一样,将有两个具有相同结果 (2) 的过程。(如果main.aux保留,则仅运行一次。)

这是main.tex

% Preamble
\documentclass[10pt]{article}

% Packages
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{subfiles}   
\geometry{a4paper, margin = 1in}

\graphicspath{{./assets/images/}} % full path to image xor_data_embedding.pdf   
% Document
\begin{document}    
    
\subfile{methodology/methodology.tex}   
    
\end{document}

这是methodology.tex

\providecommand{\fullpathtofile}{../assets/images/} %% full path to file xor_data_embedding.pdf_tex

\documentclass[../main.tex]{subfiles}

% Document
\begin{document}    
    
    \begin{figure}
        \def\svgwidth{\linewidth}
    \input{\fullpathtofile/xor_data_embedding.pdf_tex}
        \caption{Diagram}
    \end{figure}
    
\end{document

请注意,\fullpathtofile指向文件xor_data_embedding.pdf_tex不要xor_data_embedding.pdf

相关内容