Master/Child/Macro/Bibliography issues with 2.4

2024-06-20 Thread Michael Dean Pugh
I am having problems with LyX 2.4 that are so great that I don't even know 
where to begin to sort them out.  I have a LyX file which contains all the math 
macros I use regularly.  I have included (with \input) it at the very top of 
another document which is a LyX master document, containing only a title page, 
toc, lof, references to five child LyX documents (chapters. and here I used 
\include), and bibliography (thru natbib).  I am using svmono as the class 
file.  I used to have references to the macro file at the top of the five 
chapter files too, but this was apparently causing compilation problems, so I 
removed them.  But because the child (chapter) files were referencing the 
master document, which still contained the macro file as a child, they could 
still see the macros (bravo: that is exactly how it ought to work).

Yesterday, when I left school, this was working fine.  I saved everything and 
returned this morning and now nothing is working (this is not the only problem 
I am having, but I can only deal with one at time).  Now, when I try to compile 
the child documents individually they give LaTeX errors saying that the macros 
are not defined.  But the macros still work inside of LyX—it's LaTeX (well, 
technically, XeTeX) that is causing the problem.  If I put the references to 
the macro file back in the child documents, they compile individually (if I 
take out bibliography citations—this is one of the other problems)​, but then 
the master document will not compile.  It doesn't even given an error—it just 
goes forever into compile mode (wheel on task bar spins indefinitely).

So to recap:

Macro file and chapter files included in master file with (\input and \include, 
respectively) -> master compiles, chapters do not, but strangely, the math 
macros function correctly in chapter documents even though they do not​ 
individually include the macro file.  It is only when compiling that XeTeX says 
it cannot find the macros.

Macro file included in chapter and​ master documents and chapters included in 
master -> chapters compile (with bibliography citations removed) but master 
will not.

I guess I may as well include the bibliography problem here because it may be 
related.  In LyX, the chapters can "see" the bibliography entries just by 
referencing the master document if there is a \printbibliography command 
somewhere in the master.  I can see all the included entries when adding a 
citation and select what I want, just as it should work.  But when I compile 
the chapters individually, I get "citation undefined" errors in spite of this.  
Compiling the master (if I remove the macro references from the chapters) works 
fine.

I have to believe that I should be able to include references to macros and 
bibliography in the master only and still be able to compile the chapters 
individually, especially since that functionality exists inside of LyX.  Only 
when trying to compile do problems come up.  And I could have sworn all this 
was working yesterday, so I am at a loss as to what happened.  How is this 
supposed to work?

One last thing.  Yesterday, I had the bibliography settings as Style Format -> 
Biblatex (natbib mode) and Processor -> default and it was compiling.  First 
thing today, having changed nothing, I got biber errors.  I assumed that biber 
was the default processor and changed it to bibtex.  Now it works.  But I had 
previously used the aforementioned settings religiously without error.

Thanks!
Mike Pugh
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users


Re: Master/Child/Macro/Bibliography issues with 2.4

2024-06-20 Thread Richard Kimberly Heck

On 6/20/24 10:07, Michael Dean Pugh wrote:
I am having problems with LyX 2.4 that are so great that I don't even 
know where to begin to sort them out.  I have a LyX file which 
contains all the math macros I use regularly.  I have included (with 
\input) it at the very top of another document which is a LyX master 
document, containing only a title page, toc, lof, references to five 
child LyX documents (chapters. and here I used \include), and 
bibliography (thru natbib).  I am using svmono as the class file.  I 
used to have references to the macro file at the top of the five 
chapter files too, but this was apparently causing compilation 
problems, so I removed them.  But because the child (chapter) files 
were referencing the master document, which still contained the macro 
file as a child, they could still see the macros (bravo: that is 
exactly how it ought to work).


Yesterday, when I left school, this was working fine.  I saved 
everything and returned this morning and now nothing is working (this 
is not the only problem I am having, but I can only deal with one at 
time).  Now, when I try to compile the child documents individually 
they give LaTeX errors saying that the macros are not defined.  But 
the macros still work inside of LyX—it's LaTeX (well, technically, 
XeTeX) that is causing the problem.


When you compile a child by itself, it is treated as its own standalone 
document. So it's not a surprise that the macros in the master are being 
ignored. Note that there is another option: Compile the master, but only 
with certain children included. Have a look at Document> Settings> Child 
Documents. This uses \includeonly behind the scenes.



I'd be curious exactly what compilation problems are being caused by 
including the macro file multiple times. The LyX macros go into LaTeX as 
\global\long\def, and redeclaring that should not by itself cause a problem.



If I put the references to the macro file back in the child documents, 
they compile individually (if I take out bibliography citations—this 
is one of the other problems)​, but then the master document will not 
compile.  It doesn't even given an error—it just goes forever into 
compile mode (wheel on task bar spins indefinitely).
This, of course, should not happen. At this abstract level, it's hard 
even to guess why it might be. You are welcome to send me the documents, 
privately, if you wish, and I can have a look. You might also try 
simplifying the documents as much as you can, to try to localize the 
problem. (Obviously, do this on a copy.)


I guess I may as well include the bibliography problem here because it 
may be related.  In LyX, the chapters can "see" the bibliography 
entries just by referencing the master document if there is a 
\printbibliography command somewhere in the master.  I can see all the 
included entries when adding a citation and select what I want, just 
as it should work.  But when I compile the chapters individually, I 
get "citation undefined" errors in spite of this.  Compiling the 
master (if I remove the macro references from the chapters) works fine.


I have to believe that I should be able to include references to 
macros and bibliography in the master only and still be able to 
compile the chapters individually, especially since that functionality 
exists inside of LyX.  Only when trying to compile do problems come 
up.  And I could have sworn all this was working yesterday, so I am at 
a loss as to what happened.  How is this supposed to work?


See above on how compiling children works. If you really want to compile 
the children standalone, then you need to include the bibliography in 
the children but wrap it in some kind of conditional code, so it isn't 
included multiple times. This can also be done for macro includes, or 
anything else. Roughly:



[ERT]

\ifdefined\bibdone\relax\else

[\ERT]

% LyX bibliography goes here

[ERT]

\fi

\def\bibdone{true}

[/ERT]


I should perhaps add that this may work a bit differently with biblatex.


Riki

-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users


Re: Master/Child/Macro/Bibliography issues with 2.4

2024-06-20 Thread Jürgen Spitzmüller
Am Donnerstag, dem 20.06.2024 um 11:02 -0400 schrieb Richard Kimberly
Heck:
> Roughly:
>   
> [ERT]
>  \ifdefined\bibdone\relax\else
>  [\ERT]
>  
> % LyX bibliography goes here
>  [ERT]
>  \fi
>  \def\bibdone{true}
>  [/ERT]

Of use LyX branches instead of the TeX switches.


-- 
Jürgen
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users