I am using LyX to manage a multi-part document (my thesis) and I would like to be able to produce stand alone sub-documents (e.g. a chapter) that include a bibliography, but only when the sub-document is produced on its own. When I produce the full master document, the only bibliography should be at the end.

How can I make the bibliography in a LyX subdocument only show up when the document is used by itself (and not when it is included in the master document)?

2 Answers 2


After experiments using the helpful tips from this post, I found an automatic solution that works:

At the top of the master thesis document add a new TeX command (using Insert>TeX Code) that identifies that we are building the complete thesis:

\newcommand{\FULLTHESIS}{} %Id that we are building the complete thesis

Then in each chapter enclose the bibliography (or any other items that should only appear when the chapter is created standalone) between two raw TeX Code blocks as follows:

\ifdefined\FULLTHESIS\else  %TeX way of saying if not defined FULL_THESIS

Insert the Bibilography (etc) Here


Note: I could not get some of the more elegant TeX approaches from the post such as \newif and the LaTeX macro \@ifundefined to work properly in my document under LyX.


You can define a Branch for the subdocument only, which then contains the Bibliography. You can learn more about Branches in the Users Guide in section 6.8.

A good starting point to look at how that works is the thesis template which comes bundled with LyX (at least from v2.0 on).

  • 1
    Thanks for the tip... Branches do seem like a possible starting point, but they apparently still require manually selecting whether or not to include the branch text (e.g. bibilography). What I am looking for is a way to automate this such that without changing the files, the bibliography is included when run stand-alone, but not when it's a subdocument. Seems like there could be a raw LaTeX (aka ERT) solution that sets a flag in the master, and then the sub-document (chapter) could only include the text if the flag is not set. Any ideas how to do so?
    – Bryan P
    Commented Mar 5, 2012 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .