Discussion:
Compiling Root document from child document?
bigblop
2008-07-11 20:07:06 UTC
Permalink
I have made a main.lyx file that includes a few child documents as input
files. But when I am compiling a child document the whole document does not
get updated. This means that each time I want to se the changes I have made
I need to compile the main.lyx file which is rather annoying.

Is there someway to compile the main.lyx file from a child document?
--
View this message in context: http://www.nabble.com/Compiling-Root-document-from-child-document--tp18411658p18411658.html
Sent from the LyX - Users mailing list archive at Nabble.com.
James Sutherland
2008-07-11 20:56:21 UTC
Permalink
Post by bigblop
I have made a main.lyx file that includes a few child documents as input
files. But when I am compiling a child document the whole document does not
get updated. This means that each time I want to se the changes I have made
I need to compile the main.lyx file which is rather annoying.
Is there someway to compile the main.lyx file from a child document?
"Annoying" to one is a "nice feature" to another. This is actually
really a nice feature in LyX because you can actually compile and view
child documents independently from the parent, and with different
formatting (line spacing, margins, etc.). This is not easily done in
LaTeX.

I just switch the focus in LyX back to the "main" file and compile
it. Then you get the whole thing.

James
bigblop
2008-07-11 21:16:08 UTC
Permalink
If I compile the child separately the references from my .bib file does not
show (only appears as question marks).

But based on your answer it seems that my wish is not possible - you say
that I still have to manually skip to the main file to get the whole
document updated (or even a child to look correct).
Post by James Sutherland
Post by bigblop
I have made a main.lyx file that includes a few child documents as input
files. But when I am compiling a child document the whole document does not
get updated. This means that each time I want to se the changes I have made
I need to compile the main.lyx file which is rather annoying.
Is there someway to compile the main.lyx file from a child document?
"Annoying" to one is a "nice feature" to another. This is actually
really a nice feature in LyX because you can actually compile and view
child documents independently from the parent, and with different
formatting (line spacing, margins, etc.). This is not easily done in
LaTeX.
I just switch the focus in LyX back to the "main" file and compile
it. Then you get the whole thing.
James
--
View this message in context: http://www.nabble.com/Compiling-Root-document-from-child-document--tp18411658p18412701.html
Sent from the LyX - Users mailing list archive at Nabble.com.
James Sutherland
2008-07-11 22:02:32 UTC
Permalink
Post by bigblop
If I compile the child separately the references from my .bib file does not
show (only appears as question marks).
But based on your answer it seems that my wish is not possible - you say
that I still have to manually skip to the main file to get the whole
document updated (or even a child to look correct).
Right. You must compile the main file, not the children, if you want
the full document with proper cross references.

This is no different than LaTeX. There you still must compile the
"main" file and not the children. In LaTeX the problem is even a bit
worse because a "child" will not compile at all because all of the
latex preamble stuff is missing. So LyX seems to be better than LaTeX
in this regard, although not perfect since, as you point out,
references are broken...
Christian Ridderström
2008-07-11 22:55:35 UTC
Permalink
Post by James Sutherland
Post by bigblop
If I compile the child separately the references from my .bib file does
not show (only appears as question marks).
It can be done, but it's a bit more advanced and I'm not sure I remember
how I did it. Perhaps I did it by using the preamble of the child document
to define a custom command that defines the .bib-file to use, and then
inserted that custom command at the end of the child document.

Anyway, I know it can be done. If it's important, ask for it and I'll see
if I can dig out my old thesis files.
Post by James Sutherland
Post by bigblop
But based on your answer it seems that my wish is not possible - you
say that I still have to manually skip to the main file to get the
whole document updated (or even a child to look correct).
You could perhaps define your own keyboard sequence that does this for
you?

In the general case though, how would the child document know which
document that is it's master? Or... why can't a child document belong to
two or more master documents?
Post by James Sutherland
Right. You must compile the main file, not the children, if you want
the full document with proper cross references.
True.. cross references to other child documents will not work, "only"
bibilography referenes.

regards,
Christian
--
Christian Ridderström, +46-8-768 39 44 http://www.md.kth.se/~chr
bigblop
2008-07-11 23:49:40 UTC
Permalink
True.. cross references to other child documents will not work, "only"
bibilography referenes.


That only works if a bibliography section is also inserted in the child -
which is not a good idea.
--
View this message in context: http://www.nabble.com/Compiling-Root-document-from-child-document--tp18411658p18414369.html
Sent from the LyX - Users mailing list archive at Nabble.com.
Dominik Waßenhoven
2008-07-12 07:20:24 UTC
Permalink
Post by Christian Ridderström
Post by bigblop
If I compile the child separately the references from my .bib file does
not show (only appears as question marks).
It can be done, but it's a bit more advanced and I'm not sure I remember
how I did it.
Here is an example how I did it: In the main document, put these two
lines in the preamble:

,---- [master.lyx preamble] .
\usepackage{comment}
\excludecomment{subbib}
'-------------------------'

In the child documents, you have to include the following in the
preamble:

,---- [child.lyx preamble] .
\usepackage{comment}
\includecomment{subbib}
'-------------------------'

In the master document, you can include the bibliography normally. In
the child documents, however, you have to embed it in the 'subbib'
environment (which is created by the package 'comment' and the command
'includecomment'). This has to be done in ERT, not with the
bibliography-dialog:

,---- [child.lyx document] ------.
\begin{subbib}
\bibliographystyle{<bibstyle>}
\bibliography{<bib file>}
\end{subbib}
'--------------------------------'

When you now compile the master document, the 'subbib' environments are
ignored. If you compile a child document, they are included.

Regards,
Dominik.-
bigblop
2008-07-11 23:53:15 UTC
Permalink
Post by James Sutherland
Post by bigblop
If I compile the child separately the references from my .bib file does not
show (only appears as question marks).
But based on your answer it seems that my wish is not possible - you say
that I still have to manually skip to the main file to get the whole
document updated (or even a child to look correct).
Right. You must compile the main file, not the children, if you want
the full document with proper cross references.
This is no different than LaTeX. There you still must compile the
"main" file and not the children. In LaTeX the problem is even a bit
worse because a "child" will not compile at all because all of the
latex preamble stuff is missing. So LyX seems to be better than LaTeX
in this regard, although not perfect since, as you point out,
references are broken...
I know that it works with Kile for linux. There its possible to make a
project where you define a compile command that always compiles the master
eventhough you are currently editing a child. It seems that it would just be
a matter of defining a shortkey to compile a user specified .lyx file (in
this case main.lyx)
--
View this message in context: http://www.nabble.com/Compiling-Root-document-from-child-document--tp18411658p18414397.html
Sent from the LyX - Users mailing list archive at Nabble.com.
G. Milde
2008-07-14 09:35:26 UTC
Permalink
Post by bigblop
If I compile the child separately the references from my .bib file does not
show (only appears as question marks).
Insert the bibtex references inside a branch in the child document.

Either do not define this branch in the master or set it "off" there.

GM

Jürgen Spitzmüller
2008-07-12 05:14:40 UTC
Permalink
Post by bigblop
Is there someway to compile the main.lyx file from a child document?
If you have opened the child document from the master document (or after you
have once processed the master), you can compile the master from the child
with the command "master-buffer-update pdf2" (for pdflatex, as an example;
there's also master-buffer-view and you can substitute pdf2 by any output
format). You can either input this command in the minibuffer, or you can
create your own toolbar or menu item or shortcuts for this. In fact, you can
even replace the standard commands "buffer-view" and "buffer-update" with
these, since if no master is found, the document itself gets compiled.

In 1.6, things will get a bit easier. There you can allocate a master buffer
to a child in the document dialog, so the first step is not needed anymore.

Jürgen
bigblop
2008-07-12 08:42:11 UTC
Permalink
Ha! That was exactly what I needed! I just put:

\bind "M-1" "master-buffer-update pdf2"

in my bind file and know the master is compiled from the child when I press
Alt-1. A perfect and simple solution. Thanks.
Post by Jürgen Spitzmüller
Post by bigblop
Is there someway to compile the main.lyx file from a child document?
If you have opened the child document from the master document (or after you
have once processed the master), you can compile the master from the child
with the command "master-buffer-update pdf2" (for pdflatex, as an example;
there's also master-buffer-view and you can substitute pdf2 by any output
format). You can either input this command in the minibuffer, or you can
create your own toolbar or menu item or shortcuts for this. In fact, you can
even replace the standard commands "buffer-view" and "buffer-update" with
these, since if no master is found, the document itself gets compiled.
In 1.6, things will get a bit easier. There you can allocate a master buffer
to a child in the document dialog, so the first step is not needed anymore.
Jürgen
--
View this message in context: http://www.nabble.com/Compiling-Root-document-from-child-document--tp18411658p18417389.html
Sent from the LyX - Users mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...