Re: LyX-to-LyX export excluding inactive branches
On 12/19/18 9:59 PM, Bert Lloyd wrote: On Wed, Dec 19, 2018 at 7:02 PM Paul A. Rubin wrote: Might be easier to "Save as" to create a copy under a new name. The document open in LyX is now the saved copy, not the original. Go to Document > Settings... > Branches. select the answers branch, click Remove and OK, Save and you're in business. Paul I may be misunderstanding something, but for me when I Document > Settings... > Branches -> Remove, the material in the branch remains in the document, in an inset labeled "Branch (undefined): Solutions". (LyX 2.3.2 on W10) Sorry, you're right. I missed that. Maybe there should be another option in that dialog labeled "Remove completely" that would delete all instances of that branch (after a confirmation to avoid accidents). Paul
Re: LyX-to-LyX export excluding inactive branches
On 12/19/18 9:59 PM, Bert Lloyd wrote: > On Wed, Dec 19, 2018 at 7:02 PM Paul A. Rubin wrote: >> Might be easier to "Save as" to create a copy under a new name. The >> document open in LyX is now the saved copy, not the original. Go to >> Document > Settings... > Branches. select the answers branch, click >> Remove and OK, Save and you're in business. >> >> Paul > I may be misunderstanding something, but for me when I Document > > Settings... > Branches -> Remove, the material in the branch remains > in the document, in an inset labeled "Branch (undefined): Solutions". Yes, I think that is right: the branch is removed, but not the content. Riki
Re: LyX-to-LyX export excluding inactive branches
On Wed, Dec 19, 2018 at 7:02 PM Paul A. Rubin wrote: > > Might be easier to "Save as" to create a copy under a new name. The > document open in LyX is now the saved copy, not the original. Go to > Document > Settings... > Branches. select the answers branch, click > Remove and OK, Save and you're in business. > > Paul I may be misunderstanding something, but for me when I Document > Settings... > Branches -> Remove, the material in the branch remains in the document, in an inset labeled "Branch (undefined): Solutions". (LyX 2.3.2 on W10)
Re: LyX-to-LyX export excluding inactive branches
Messed up and sent this to Bert rather than to the list. :-( On 12/19/18 11:18 AM, Bert Lloyd wrote: Dear LyX Users, When writing problem sets, I create a Solutions branch so that I can maintain just a single LyX file. I like to give students .tex and .lyx files so they can type up their solutions. Creating a .tex file without the content of the Solutions branch is very easy - I just toggle off the Solutions branch and export to .tex in the usual way. Is there a similar way to "export" (or just save-as) a .lyx file without deactivated branches? At the moment, my workaround is to export to tex and then import tex to lyx. Many thanks, BL Might be easier to "Save as" to create a copy under a new name. The document open in LyX is now the saved copy, not the original. Go to Document > Settings... > Branches. select the answers branch, click Remove and OK, Save and you're in business. Paul
Re: LyX-to-LyX export excluding inactive branches
On 12/19/18 11:18 AM, Bert Lloyd wrote: > Dear LyX Users, > > When writing problem sets, I create a Solutions branch so that I can > maintain just a single LyX file. I like to give students .tex and .lyx > files so they can type up their solutions. > > Creating a .tex file without the content of the Solutions branch is > very easy - I just toggle off the Solutions branch and export to .tex > in the usual way. > > Is there a similar way to "export" (or just save-as) a .lyx file > without deactivated branches? At the moment, my workaround is to > export to tex and then import tex to lyx. There *might* be a way to do this with the inset-forall LFUN, but I wouldn't know for sure. Depending upon how many there are, you could try using the outliner, sorting by branch name, and deleting manually. Another option, which is always available, is to write some kind of perl or python script to remove the unwanted branches from the LyX file directly. Something like (in perl): $inset_count = 0; $in_branch = 0; while (<>) { if (m{^//begin_inset Branch Solution}) { $in_branch = 1; $inset_count = 1; } elsif ($in_branch) { if (m{^\\begin_inset}) { $inset_count++; } elsif (m{\\end_inset}) { $inset_count--; } if ($inset_count == 0) { $in_branch = 0; } } else { print; } } Not tested!! (Usage: perl thatfile.pl < oldfile.lyx >newfile.lyx) It's one nice thing about LyX files being just flat text files that you can do this kind of thing so easily. Riki