Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\input@path is not honored by usetikzlibrary #1259

Open
tobiasBora opened this issue May 10, 2023 · 4 comments
Open

\input@path is not honored by usetikzlibrary #1259

tobiasBora opened this issue May 10, 2023 · 4 comments

Comments

@tobiasBora
Copy link

tobiasBora commented May 10, 2023

Brief outline of the bug

As far as I see, there is no way to add a folder to the search path of tikz. This becomes very annoying when importing a file in a subfolder that requires a custom tikz library, or when my custom libraries are not put at the root of my project.

More precisely, I have a structure like this (see below for exact content):

mycachedfiles/a.tex
myinput.tex
tikzlibrarymy.test.code.tex

I’d like to compile it using:

cd mycachedfiles
pdflatex a.tex

However, if myinput.tex contains \usetikzlibrary{my.test}, then I will get an error like:

! Package tikz Error: I did not find the tikz library 'my.test'. I looked for f
iles named tikzlibrarymy.test.code.tex and pgflibrarymy.test.code.tex, but neit
her could be found in the current texmf trees..

By default, LaTeX will try to search in folders listed in \input@path, so \input{tikzlibrarymy.test.code.tex} would work… unfortunately \usetikzlibrary gives an error without even trying to run the \input.

Minimal working example (MWE)

MWE

% a.tex:
\documentclass[]{article}
\makeatletter
% Works for \input{} but not for \usetikzlibrary
\def\input@path{{..}}
\makeatother

\input{../myinput.tex} % no more success with subimport

\begin{document}

\begin{tikzpicture}
  \node[my test style]{A};
\end{tikzpicture}

\end{document}
% myinput.tex
\usepackage{tikz}
\usetikzlibrary{my.test}
% tikzlibrarymy.test.code.tex:
\tikzset{
  my test style/.style={
    draw,
    circle,
    fill=red,
  }
}
@muzimuzhi
Copy link
Member

Similar: #565

A more general question: In LaTeX format, should pgf's \pgfutil@IfFileExists respect \input@path as its LaTeX relative \IfFileExists does? This would affect the loading of library/module, .table files, and of course images.

Originally posted by @muzimuzhi in #980 (comment)

@hmenke
Copy link
Member

hmenke commented May 10, 2023

\input@path is a LaTeXism and not portable across format.

@tobiasBora
Copy link
Author

Then wouldn't it be possible to define another variable for that? Or provide this functionality only for LaTeX?

@muzimuzhi
Copy link
Member

muzimuzhi commented May 11, 2023

Perhaps \pgfutil@IfFileExists can be extended to take a list of directories, for example \pgfinputpath, into consideration. Then in LaTeX format \pgfinputpath can be initialized to \input@path at some early stage in loading pgf or tikz package. In formats other than LaTeX \pgfinputpath can be defined by user before pgf or tikz is loaded.

Update: also \pgfutil@InputIfFileExists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants