0

Depending on the previous text I need to set e path to folder 1 or folder 2. With just one folder everything worked fine, but with the condition it doesn't. What am I missing?

\newcommand{\nc}{text-a}

\ifthenelse{\equal{\nc}{text-a}}
{
    \makeatletter
    \def\input@path{{"../folder-1/"}}
    \makeatother
}{
    \makeatletter
    \def\input@path{{"../folder-2/"}}
    \makeatother
}

edit: unfortunately it does not go this way either:

\newcommand{\nc}{text-a}

\makeatletter
    \ifthenelse{\equal{\nc}{text-a}}{
       \def\input@path{{"../folder-1/"}}
    }{   \def\input@path{{"../folder-2/"}}
    }
\makeatother
  • 1
    Did you try moving the \makeatletter before the \ifthenelse{\equal{\nc}{text-a}} and the \makeatother to after the entire block (I didn't test this suggestion for lack of an MWE)? IIRC the category code can't be changed within arguments of macros, this has to be done 'outside'. – moewe Jun 28 at 6:47
  • @moewe Yes, I already tried to do it like this but I got the same problems. – GuestUser Jun 28 at 7:01
  • 2
    @GuestUser \makeatletter can not work inside the argument of a command (same reason as \verb not working there) move them outside – David Carlisle Jun 28 at 7:04
  • @DavidCarlisle unfortunately it does not go this way either. – GuestUser Jun 28 at 13:20
  • @GuestUser that sets the path, if that path does not work then you have an error in code not shown – David Carlisle Jun 28 at 13:42
2

The posted code does set the path conditionally, the test file below shows both settings:


LaTeX2e <2018-12-01>
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty)
> \input@path=macro:
->{"../folder-1/"}.
l.13 \show\input@path

? 
> \input@path=macro:
->{"../folder-2/"}.
l.26 \show\input@path

? 
 )
No pages of output.

\RequirePackage{ifthen}

\newcommand{\nc}{text-a}

\makeatletter
    \ifthenelse{\equal{\nc}{text-a}}{
       \def\input@path{{"../folder-1/"}}
    }{   \def\input@path{{"../folder-2/"}}
    }
\makeatother

\makeatletter
\show\input@path
\makeatother

\renewcommand{\nc}{text-b}

\makeatletter
    \ifthenelse{\equal{\nc}{text-a}}{
       \def\input@path{{"../folder-1/"}}
    }{   \def\input@path{{"../folder-2/"}}
    }
\makeatother

\makeatletter
\show\input@path
\makeatother



\stop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.