-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
\graphicspath
' argument cannot contain macros anymore
#1086
Comments
Seems a l3kernel issue.
\RequirePackage{latexbug} % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\usepackage{graphicx}
\makeatletter
\ExplSyntaxOn
\cs_gset:Npn \__file_full_name_auxii:nn #1 #2
{
\tl_if_blank:nTF {#2}
{
\seq_map_tokens:Nn \l_file_search_path_seq
{ \__file_full_name_aux:Nnn \seq_map_break:n {#1} }
\cs_if_exist:NT \input@path
{
\tl_map_tokens:Nn \input@path
{ \__file_full_name_aux:Nne \tl_map_break:n {#1} } % <<< changed
}
\__file_name_end:
}
{ \__file_ext_check:nn {#1} {#2} }
}
\cs_generate_variant:Nn \__file_full_name_aux:Nnn {Nne}
\ExplSyntaxOff
\makeatother
\begin{document}
Explicit path
{
\graphicspath{{images/}}
\includegraphics[width=3cm]{example-image-renamed}
}
{
\makeatletter
\def\input@path{{images/}}
\IfFileExists{example-image-renamed.pdf}TF
[\UseName{file_full_name:n}{example-image-renamed.pdf}] % before
\@iffileonpath{example-image-renamed.pdf}TF
\makeatother
}
Macro as path
\newcommand{\imagesdir}{images}
{
\graphicspath{{\imagesdir/}}
\includegraphics[width=3cm]{example-image-renamed}
}
{
\makeatletter
\def\input@path{{\imagesdir/}}
\IfFileExists{example-image-renamed.pdf}TF
[\UseName{file_full_name:n}{example-image-renamed.pdf}] % before
\@iffileonpath{example-image-renamed.pdf}TF
\makeatother
}
\end{document} |
Yeah,
I can't try now, but I can't see a reason for the |
From doc for
|
Grrrrr For |
Like this?
\RequirePackage{latexbug} % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\usepackage{graphicx}
\makeatletter
\ExplSyntaxOn
\cs_gset:Npn \__file_full_name_auxii:nn #1 #2
{
\tl_if_blank:nTF {#2}
{
\seq_map_tokens:Nn \l_file_search_path_seq
{ \__file_full_name_aux:NnNn \seq_map_break:n {#1} \tl_to_str:n }
\cs_if_exist:NT \input@path
{
\tl_map_tokens:Nn \input@path
{
\__file_full_name_aux:NnNn
\tl_map_break:n {#1} \__file_name_expand:n
}
}
\__file_name_end:
}
{ \__file_ext_check:nn {#1} {#2} }
}
\cs_new:Npn \__file_full_name_aux:NnNn #1#2#3#4
{
\exp_args:Ne \__file_full_name_aux:nN
{
\exp_args:Ne \__file_full_name_slash:n { #3 {#4} } #2
}
#1
}
\ExplSyntaxOff
\makeatother
\begin{document}
Explicit path
{
\graphicspath{{images/}}
\includegraphics[width=3cm]{example-image-renamed}
}
{
\makeatletter
\def\input@path{{images/}}
\IfFileExists{example-image-renamed.pdf}TF
\beginunravel
[\UseName{file_full_name:n}{example-image-renamed.pdf}]
\endunravel
\@iffileonpath{example-image-renamed.pdf}TF
\makeatother
}
Macro as path
\newcommand{\imagesdir}{images}
{
\graphicspath{{\imagesdir/}}
\includegraphics[width=3cm]{example-image-renamed}
}
{
\makeatletter
\def\input@path{{\imagesdir/}}
\IfFileExists{example-image-renamed.pdf}TF
[\UseName{file_full_name:n}{example-image-renamed.pdf}]
\@iffileonpath{example-image-renamed.pdf}TF
\makeatother
}
\end{document} Also the TeXhackers note for
|
Haven't tested, but looks good! Though I do wonder about |
I was just going to make the same observation. I think we could consider this |
The |
As @muzimuzhi notes, I added this at the same time as other |
I can see a stronger argument for expansion in |
I'd say for any user documented command such as |
OK, so the only question then is do others agree with me at the code level? A change is easy enough either way, so it's not a technical issue. |
Not really:-) but it doesn't matter much at the L3 level, as, as you say, you can control expansion when adding to the sequence. So happy enough that the l3 sequence is a str so in practice would always be built using |
That's rather what I was getting at: typically, in |
same as any use of macros, to gain a level of indirection. if I don't see macros that finally expand to stringified filenames any differently to macros expanding to typeset text so the "not really" answer is because I don't see that the fact the end use is a string has any bearing on whether expansion should be suppressed (well except when it has to as tex is tex) |
@davidcarlisle I can see that there is a difference between a file name (where we can rely on
I realise I might be a bit risk-averse in file naming: comes from my day job I suspect. |
Obviously, if the consensus is to change, I'll sort (I can do an |
I've thought about this and on balance I'd like to keep users happy, so I'll make the change in |
@davidcarlisle Quick query. Should \def\foo{{./bar/}{./baz}}
\def\input@path{\foo} |
to cover that ll you need is one |
I was thinking simple |
Testing on overleaf's texlive 2022 (latex2e 2022-06-01 PL5) and on local texlive 2023 with rollback both show \def\foo{{./bar/}{./baz}}
\def\input@path{\foo} is not supported before. |
I will have |
Good to know, but not that relevant here in my opinion. The example use case that David gave could easily be of that nature. And supporting it should be trivial. so I would do both. |
But that's putting the internal detail of the implementation of a data structure into a macro and expecting it to 'jsut work'. It might feel reasonable for |
They are very different changes conceptually: one is to not suppress expansion of values passed from an iteration, the other is to force expansion and hope it produces something that is then suitable for iteration at all. |
I see no "seq" above :-) In my opinion it should work for |
sorry don't see the argument. |
Feels to me like the difference between allowing |
(I'll hold off on the |
BTW, checking back the oldre mechanism does \expandafter \@tfor \expandafter \reserved@b \expandafter :\expandafter =\input@path \do { ... } so would only work as already observed with brace groups directly inside |
@davidcarlisle Thoughts? |
I don't insist on making it more flexible if that is what it was for the last 30odd years |
Code has gone to CTAN today |
sorry I know it's gone out already, but for the record I think that's OK |
Brief outline of the bug
In
\graphicspath
' argument, the paths could be specified via macros, as follows:This is no longer the case with an updated version of TeX Live 2023 (
LaTeX2e <2023-06-01>
):Minimal example showing the bug
When the following example:
is compiled with
LaTeX2e <2023-06-01>
, the following error occurs:In order to let you easily test this project, the structure of which being:
here are an archive of it and an Overleaf clone of it which show that
\graphicspath
' argument containing macros, respectively:LaTeX2e <2022-06-01> patch level 5
).Log file (required) and possibly PDF file
test-graphicspath.log
The text was updated successfully, but these errors were encountered: