Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to have recursive path in the command \input@path, but it seems to be impossible (as I read, I'm with the TexLive 2012 and Linux).

So I had the following idea, make a loop in \input@path, but it doesn't work and I don't know why ...

This is what I did :

\newcounter{path}
\setcounter{path}{0}
\def\nom{%
  \ifcase\thepath Cours%
  \or Livres%
  \fi
}
\def\input@path{%
 \loop \ifnum \thepath<3
   {~/Exercices/\nom/Derivee/}
 \stepcounter{path} \repeat
}

If someone have an idea, it will be very helpful.

share|improve this question
1  
Welcome to TeX.SX! Please add a fully compilable minimal working example (MWE) that illustrates your problem. In particular it is not obvious what you are trying to achieve. Maybe you could provide some context? –  canaaerus Aug 26 '12 at 16:33
    
Thx for the welcome ... For the MWE, it is a little difficult, but I can try. Just try to explain better (sorry for my english, I'm french). So what I want it's to make a loop in input@path (to make a minimal code in input@path, I have a lot of directories), so when I do an \input{foo} in my main file, Latex can find my foo.tex everywhere... I don't know if it better ? –  Coyote Aug 26 '12 at 17:11
1  
If you really have a lot of directories, then it might be adviseable to put the root of all of them into TEXMFHOME and run texhash to index all of them. Run texdoc texlive for infos on configuration. These variables are not strictly meant for this sort of thing, but by putting a large number of items in input@path, you are forcing LaTeX to explicitly iterate through all of them for every input, which can get time consuming. –  Stephan Lehmke Aug 26 '12 at 17:24

1 Answer 1

The format of \input@path is fixed, each path entry is surrounded by curly braces without further separators. Any other stuff such as loops are forbidden. But it is possible to add entries:

\makeatletter
\newcounter{path}
\setcounter{path}{0}
\newcommand*{\nom}{%
  \ifcase\value{path}%
    Cours% 0
  \or
    Livres% 1
  \or
    Two% 2
  \fi
}
\@ifundefined{input@path}{%
  \let\input@path\@empty
}{}
\loop
\ifnum\value{path}<3 %
  \edef\input@path{%
    \input@path
    {\string~/Exercises/\nom/Derivee/}%
  }%
  \stepcounter{path}%
\repeat
\typeout{input@path: \input@path}
\makeatother

Some remarks:

  • The input strings are expanded by \edef, because sooner or later they are expanded anyway. The tilde ~ is usually an active character, to prevent expansion, it is prefixed by \string that converts the active to a non-active character (with catcode 12).

  • The example uses \value{<counter>} instead of \the<counter>, because the latter form is intended for printing and might not always expand to a plain arabic number.

  • The definition for number 2 in \ifcase was missing.

share|improve this answer
    
Wonderful :-) That's works perfectly ! Sorry for the number two and ~, it was very bad mistakes, please accepts my excuses. For the difference between \value{<counter>} and \the{<counter>}, I don't understand ! \the<counter> can produce roman or alpha counter, isn't it ? And `\value{<counter>}è is always arabic ? In all case, a great thx for your help ! –  Coyote Aug 26 '12 at 19:31
    
I guess it is the same for \graphicspath ? Or may be not ? –  Coyote Aug 26 '12 at 20:00
    
Yes, \graphicspath and \input@path use the same data format. –  Heiko Oberdiek Aug 26 '12 at 20:11
    
\value{<counter>} is the counter register, whereas \the<counter> is the counter representation, as default an arabic number that might be redefined. –  Heiko Oberdiek Aug 26 '12 at 20:21
    
Thx again for yours answers .... I take your code and change input@path by graphicspath and \input@path by \graphicspath ... but it doesn't work, I have this : !Argument of \graphicspath has an extra }. Damn it ! –  Coyote Aug 26 '12 at 21:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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