Hi Jim,

Jim <[email protected]> writes:

> Ikumi gave an example of including sub-files with \input earlier
> today.  Is that what you are thinking of?

Yes, exactly.  And the important bit is:

  As you see, the sub file doesn't have preamble.

> If not, before I (attempt to) do that... Is there some definitive arbiter
> who can decree, from on high, "what AUCTeX is supposed to do" in these two
> cases:
>
> (1) editing sub-file without \usepackage{standalone) / 
> \documentclass{standalone}
>     What should happen for each of
>     C-c C-c
>     C-c C-b
>     C-c C-r
>     vis-a-vis hunting for preamble material, assuming TeX-master points to
>     the master file?

With this setup, everything should work as expected and described in the
manual[1]:

  1.3.2.4 Running LaTeX on parts of your document

  If you want to check how some part of your text looks like, and do not
  want to wait until the whole document has been typeset, then mark it
  as a region and use C-c C-r. It behaves just like C-c C-c, but it only
  uses the document preamble and the region you marked.

  If you are using \include or \input to structure your document, try
  C-c C-b while you are editing one of the included files. It will run
  latex only on the current buffer, using the preamble from the master
  file.

> and
>
> (2) editing sub-file *with* \usepackage{standalone) / 
> \documentclass{standalone}
>     What should happen for each of
>     C-c C-c
>     C-c C-b
>     C-c C-r
>     vis-a-vis hunting for preamble material, assuming TeX-master points to    
>     the master file?

I think this a false assumption in general: When using the standalone
bundle, you don't set `TeX-master' to the master file; each standalone
sub-file is a master file.

> And I further imagine that if someone has *not* set up the standalone stuff
> in the master file and sub-file, they won't attempt to compile the sub-file
> by itself with any preamble other than what is in the master file.
>
> Does that agree with your ideas about this?

I'm not sure if I understand the above.  Let me add an example given in
standalone.pdf.  It says (I've added the file local vars):

--8<---------------cut here---------------start------------->8---
% Main file
% Real document class:
\documentclass{article}
% Use the `standalone' package:
\usepackage{standalone}
% Load all packages needed for all sub−files:
\usepackage{tikz}
% Inside the real `document' environment
% read the sub−file with `\input'
\begin{document}
% ...
\begin{figure}
  \input{subfile}
  \caption{A subfile}
\end{figure}
% ...
\end{document}

%%% Local Variables:
%%% mode: LaTeX
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
% A sub−file (e.g. picture) using the `standalone' class:
% Use `standalone' as document class:
\documentclass{standalone}
% Load packages needed for this TeX file:
\usepackage{tikz}
% Surround TeX code with `document' environment as usually:
\begin{document}
% Add your TeX code, e.g. a picture:
\begin{tikzpicture}
  \draw (0,0) rectangle (2,1) node [midway] {Example};
\end{tikzpicture}
\end{document}

%%% Local Variables:
%%% mode: LaTeX
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

As you see, the general approach with standalone is different from what
Keita sent.  I still think that setting `TeX-master' to master file in
the sub-file is wrong since the whole idea behind standalone is lost
then.  So we don't need to adjust AUCTeX in this regard.  The question
is if this also works for ConTeXt, that's the part I can't tell.

Best, Arash

Footnotes:
[1]  
https://elpa.gnu.org/devel/doc/auctex.html#Running-LaTeX-on-parts-of-your-document

Reply via email to