0

I am trying to include diagrams in the tex file using .pdf_tex files using 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}

The methodology.tex file containing the .pdf_tex call:

% 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}

Was hoping for a output like this enter image description here but alas.

But I can not seem to figure out how to solve the issue. It says it can't load the file but I can't seem to figure out why.

Terminal Output:

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

I do not think I missed placing the xor_data_embedding.* files in their correct folders.

Folder Structure:

.
|
+---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

The diagram was made using Adobe Illustrator and exported into a .svg, then converted into .pdf_tex using Inkscape. The files are here if required.

Any guidance is extremely appreciated.

Rashiq
  • 337
  • 1
    Have you tried to define graphicspath and declaregrahpichextension{pdf}? Sometimes it has happened to me that if you do not do that, the PDF_TEX file does not found its corresponding PDF file, which seems to be the error in your log – Jes Mar 28 '21 at 01:45
  • This question does not involve amsmath, so I've removed that tag. – barbara beeton Mar 28 '21 at 02:08
  • Add \graphicspath{{./assets/images/}} before \begin{document} in main.tex. – Simon Dispa Mar 28 '21 at 13:44
  • @Simon Dispa It is working but can you explain why it doesn't find the path when specified directly? – Rashiq Mar 29 '21 at 20:21
  • I added an explanation, expecting to clarify your doubts. – Simon Dispa Mar 30 '21 at 16:10

1 Answers1

0

Why it doesn't find the path when specified directly?

Because there are two different paths: (a) to the image xor_data_embedding.pdf as seen from main.tex, and (b) to the file xor_data_embedding.pdf_tex.

methodology.tex inputs the file ../assets/images/xor_data_embedding.pdf_tex which is able to happily produce a figure as output using xor_data_embedding.pdf sitting its same directory.

There are three possible cases to test:

(1) Run methodology.tex commenting \subfile{methodology/methodology.tex} in main.tex

It will generate methodology.pdf in its own directory using

.././assets/images//xor_data_embedding.pdf' as source.

It does not need \graphicspath{{./assets/images/}} in main.

(2) Run main.tex , now including \subfile{methodology/methodology.tex}

The compiler will run twice, but this is not related with paths or subfiles.

Adding \graphicspath{{./assets/images/}} points main.tex to the figure and it will generate main.pdf in the root directory now using ./assets/images//xor_data_embedding.pdf as source.

(3) Run methodology.tex, including \subfile{methodology/methodology.tex} in main.tex, deleting before all files from the root directory except main.tex.

As before there will be two process with the same result of (2). (only one run if main.aux was kept.)

This is a MWE of 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}

This is 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

Note that \fullpathtofile points to the file xor_data_embedding.pdf_tex not to xor_data_embedding.pdf

Simon Dispa
  • 39,141
  • So, if I have a say another folder in assets, or anywhere, called diagrams. I would have to add \graphicspath{{./assets/diagrams/}} in the main.tex and repeat for as many folders I have? Wouldn't that count as repetition or is that the recommended way to do things? Thank you for the detailed explanation. – Rashiq Mar 31 '21 at 16:16
  • @Rashiq Like \graphicspath{{<path1>}{<path2>}{<path3>}} with nothing in between the braces. – Simon Dispa Mar 31 '21 at 16:42