3

I'm inputting a file from within a master document (the WinEdt Project's Main file) named "MyDocument.tex" by using the \jobname command as per the MWE below.

% This is the file named "MyDocument.tex", from where I input 
% the file named "MyDocumentBody.tex" via \input{\jobname Body.tex}

\documentclass{article}

\begin{document}
\input{\jobname Body.tex}
\end{document}   

The WinEdt Tree window displays a warning sign informing that the file named "\jobname Body.tex" cannot be found, which is otherwise located, and the corresponding WinEdt Tree TOC perfectly expanded, if I use the actual filename "MyDocumentBody.tex" (current expansion of \jobname).

Both files are in the same directory and the compilation runs smoothly nonetheless, so this is just about the WinEdt Tree.

Is it possible, and in the affirmative, how, to proceed inputting the file as I do and also have the file's TOC available in the WinEdt Tree window? Currently I'm still using WinEdt 8.0, so an answer working for this version would be most welcome.

  • 2
    The WinEdt Tree window doesn't know TeX and so it cannot expand \jobname. – egreg Aug 9 '16 at 9:58
  • @egreg Nonetheless, I believe WinEdt may have its own resources to be customised and have it learn about some TeX commands in a similar way as it does with structural divisions, labels, etc. – Marcos Aug 9 '16 at 10:02
  • @egreg Just for the record. You are actually right in your assertion, my point being that we can teach WinEdt on what to do when finding at least some fraction of TeX commands. – Marcos Aug 9 '16 at 12:03
4

This is quite simple. Follow these steps:

  1. Show the "Options Interface" (Options -> Options Interface)

    enter image description here

  2. In the "Options Interface", double-click the "Input Directives" item (Input.ini gets opened)

  3. Locate the line

      DIRECTIVE="\input{?}"
    

    and just after it insert the lines

        FILENAME="%[!|LetReg(0,'%?');"+
                 "SubstituteInString('%!0','\jobname','%N',10,0);"+
                 "SubstituteInString('%!0',' ','',10,0);|];%!0"
    
  4. Press Shift+Ctrl+F9 to reload the file.

  5. Go to your document and press F5 to rebuild the tree.

Now your MyDocumentBody.tex file is collected in the "Tree" interface:

enter image description here

| improve this answer | |
  • This works with WinEdt 10.x (I've tried with a trial version). Nonetheless, with WinEdt 8.0 I get the warning "Numeric Expression in Range [0..9] expected" from ExeScript.edt. Could you possibly provide any hints about an amendment for 8.0? – Marcos Aug 9 '16 at 11:59
  • @Marcos now it should work in any version >7. – karlkoeller Aug 9 '16 at 16:11
  • Now it works perfectly. – Marcos Aug 9 '16 at 18:30

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.