If you have \includeonly{chapter1.tex} in your main.tex, then you don't need to do anything. The usual commands work in both files as long as the TeX-master local variable is set to main.tex.
Change the \includeonly as needed or comment it out to compile the whole document. All the best, Greg > ---------------------------------------------------------------------- > Date: Sun, 15 Dec 2024 14:32:17 -0500 > From: Kourosh Kalayeh <k.kala...@gmail.com> > To: auctex@gnu.org > Subject: Compiling Individual Files in Multi-File Projects > Message-ID: <m05xnkn3ni....@gmail.com> > Content-Type: text/plain; charset="utf-8" > > HI everyone, > > I am looking for a way to compile a single file in a multi-file LaTeX project > without adding a standalone preamble to the subfiles. The goal is to compile > the subfile while still using the preamble and settings defined in the main > document. > > I am working on a large document (=main.tex=) that is comprised of different > sections (=chapter1.tex=, =chapter2.tex=, etc). Currently, I am using > =\include= command in =main.tex= to compile the full document, and this works > well. > > However, I also want the flexibility to compile individual files (e.g., > =chapter1.tex=) separately, so I can send them out for review and > feedback. Ideally, this should use the preamble and settings from =main.tex= > without requiring me to manually copy or add a preamble to the subfiles. > > Is there a recommended workflow in AUCTeX for such cases? Specifically: > > 1. How can I set up AUCTeX to compile subfiles individually, leveraging the > main file’s preamble? > > 2. Is TeX-region the best approach for this? If so, how should I configure it > for this use case? > > I’d appreciate any suggestions, configurations, or workflows you’ve found > effective for this scenario. > > Thanks, > Kourosh