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 have several files open in winedt that are all related in a sort of project. I have the main file that includes the other files.

Is there any way to set it up so when I compile any one of the files it compiles the main one instead(and saves the others)? I don't mind hard coding the file names if necessary.

I'd like to have a custom icon for this so that any time I'm working on a large multifile project I can modify the icon to compile the main file.

share|improve this question
    
You need to set the "Main File" for the project under the Project menu. The currently set main file should be displayed in the status bar and compile be default. –  Werner May 13 '12 at 3:14
    
@Werner I don't know what you mean by "compile be default". When I click the "compile" button it just compiles the current file. The project is set for my main file that I want to compile but I don't see where to compile it at. –  Uiy May 13 '12 at 4:05
    
From this help file: "Note that your actual position was in the Introduction Chapter (T0.tex). So, how did WinEdt know to compile the main file Thesis.tex rather than the current chapter (which would fail to compile without a proper preamble present in the main file). This is because Thesis.tex is set as the main file...For your convenience the name of the currently set main file is displayed in the last panel of WinEdt's status line..." –  Werner May 13 '12 at 4:38
    
@Werner Ok, the problem is that you must use \include for winedt to find the files then build all. The problem is I modified the include macro to use spaces(I build the file name in lua so I can simply do \incfile{"My spaced filename"}. Winedt doesn't like this. –  Uiy May 13 '12 at 4:43
1  
TeX and related tools really don't like spaces in file names. There is a strong presumption against using them. –  Joseph Wright May 13 '12 at 8:07

1 Answer 1

WinEdt requires one to use \include for it to know the included files to the main target file. If you use spaces in your includes then it will break tex. A work around is to wrap include to insert \space for spaces:

Here is a lua function that will convert the filename to something tex will recognize properly:

function tex.ConvertToSpace(str)
    str = string.gsub(str, " ", "\\space ")
tex.print('\\incfile{"'..str..'"}')
end

And here is a modification of the \include command that will allow WinEdt to work properly:

\let\incfile\include
\renewcommand{\include}[1]{\directlua{tex.ConvertToSpace("#1")}}

Simply call it like you would normally

\include{My filename with spaces}
share|improve this answer

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.