0

When trying to nest \url or \path within a for-each loop (not to be confused with TikZ paths), the text from the loop is not printed:

MWE:

\documentclass{article}

\usepackage{pgffor}
\usepackage[obeyspaces]{url}

\begin{document}

\providecommand{\test}{}%
    \foreach \x in {%
        folder1/part_1,
        folder2/part_2%
    }{
   \gdef\test{\path{\x}}%
    \test}

\end{document}

Output:

\x \x

Desired Output:

folder1/part_1 folder2/part_2

I have nested the output within a command for use elsewhere for another function (but the problem exists even without using commands).

2
  • Shouldn't you be using \x plus you need to expand \x inside \path
    – daleif
    Commented May 15, 2021 at 7:47
  • Apologies; a typo - fixed above and still has a problem. How would expand be implemented?
    – Harry
    Commented May 15, 2021 at 7:53

1 Answer 1

1

An example that shows, how to expand the argument \x of \path (or \url). The wrapper with macro \test is removed, it does not serve a purpose in the example:

\documentclass{article}

\usepackage{pgffor}
\usepackage[obeyspaces]{url}

\begin{document}

\foreach \x in {%
    folder1/part_1,
    folder2/p a r t_2%
}{%
  \expandafter\path\expandafter{\x}
}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .