GeneralProcess only selected Parts of a Document

General information and discussion about TeXnicCenter
Post Reply
gnreis
Posts: 2
Joined: Tue Sep 14, 2010 4:54 pm

Process only selected Parts of a Document

Post by gnreis »

Dear community:

Setup:
I'm writting a book and using texniccenter. For each chapter I have a tex file that is called by the main file via the input command.

My Problem:
when I change one (chapter) file and compile the main file, texniccenter compiles all files of the project (as is supposed). Since the files have lots of information written on them this takes a while.

What I'm looking for:
I would like to configure texniccenter in such a way, that he would only compile the changed files and use the information of the previous compilation concerning the other unchanged files of the project.
This I suppose, would make compilation much faster.

"Somewhere else has done it"...:
Well, my colleagues that use MACs can do this by adding a special line at the beginning of the tex file. Something like this (for the program they use on their MAC to compile latex):

Code: Select all

% !TEX root = ./book.tex
So I wonder if it possible to do the same for texniccenter.

Thanks you very much.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Process only selected Parts of a Document

Post by localghost »

gnreis wrote:[…] What I'm looking for:
I would like to configure texniccenter in such a way, that he would only compile the changed files and use the information of the previous compilation concerning the other unchanged files of the project.
This I suppose, would make compilation much faster. […]
When splitting the input, you should better use the commands \include (← Link!) and \includeonly (← Link!) to get the workflow you want. However, this is not an automatism. See this (fictional) document as a demonstration.

Code: Select all

\documentclass[11pt]{report}
% usually some packages are loaded here

\includeonly{   % Of course this list allows many more file
%  intro,       % should also work with files in different paths
%  chapter1,
  chapter2,
%  chapter3
}

\begin{document}
  \tableofcontents

  \include{intro}     % should also work with files in different paths
  \include{chapter1}
  \include{chapter2}
  \include{chapter3}
\end{document}
This example shows a document with an introduction and three chapters where only the second one is compiled. The single files are located in the working directory. If not, the commands should also work with (relative) paths.
gnreis wrote:[…]"Somewhere else has done it"...:
Well, my colleagues that use MACs can do this by adding a special line at the beginning of the tex file. Something like this (for the program they use on their MAC to compile latex):

Code: Select all

% !TEX root = ./book.tex
So I wonder if it possible to do the same for texniccenter.[…]
That is not correct. Your colleagues seem to use TeXShop on their machines. What they do with this "magic" comment (at the very beginning of every file except for the master file) is to determine the master file (root) of the project. That is to say the file that usually contains the preamble. This is helpful because you don't always have to go to the master file just to compile the document. These comments also work in TeXworks. You could say that this is a rudimentary method of project support as you know it from TeXnicCenter (TXC). At least for TeXworks it is planned to expand this feature (according to the roadmap).

The best way to control which part of the document is compiled is the method I introduced above. This is easy to achieve because it only needs to comment the files that shall not be compiled in the list of the \includeonly command. This way of compiling a certain part of the document has one more advantage. The \include command produces auxiliary files (*.aux) for all source files. All these files of the project will be used, so that lists like the ToC will look like in the complete document.


Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply