LyXCreating a controllable text "Layer" in a master document

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
Polaris96
Posts: 5
Joined: Thu Aug 15, 2013 8:55 pm

Creating a controllable text "Layer" in a master document

Post by Polaris96 »

Hello Everyone,

I'm a complete n00b at LyX and haven't yet messed with LaTeX, at all. I've produced several documents in LyX and love it. I need help with a bit of complicated formatting that I'm pretty sure can be done... it just escapes me.

I'm writing an Instructor's Guide for an adult training course which will contain the student handbook as part of the instructor material. I want to create an overlay environment, like a CAD layer, which could be made visible for producing the instructor guide, but could be toggled to remove all the instructor advice from the student guide. I could then produce both the Instructor Guide and Student Guide from the same source.

I basically only want to type the information once and use the program to separate instructor advice from what is visible to the student. Does such a construct exist in LyX or LaTeX?

Thanks in advance and apologize if the question was basic.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Polaris96
Posts: 5
Joined: Thu Aug 15, 2013 8:55 pm

Re: Creating a controllable text "Layer" in a master documen

Post by Polaris96 »

wow. I guess it's a good question... Thanks for all the looks. I'm thinking about creating a module, now. Again, any input about what's out there would be appreciated.
Polaris96
Posts: 5
Joined: Thu Aug 15, 2013 8:55 pm

Re: Creating a controllable text "Layer" in a master documen

Post by Polaris96 »

OK. So, at this point, I've pretty much decided to move forward with a home-baked module to create layering. That said, there are 2 caveats: 1) I need to move forward on my actual "work" project, and 2) This is at the hairy edge of my abilities, so I've got to acquire some technical knowledge to complete things.

I'm going to annotate the process here because I hope it may interest people and hopefully generate some feedback. Comments are highly solicited and deeply appreciated!

****BEGIN
I'm a hardware engineer with a heavy UNIX background. I'm a decent structured programmer. I've got a working knowledge of OOP but haven't used it much (not a software developer by trade). I know a fair bit about Markup Languages (HTML, XHTML), but not LATEX, specifically.

Here's how I plan to handle the project:

The basic idea is a master document containing $EVERYTHING. The "layers" will be markup that sits above the normal typesetting. Layers will be named and each name be tied to some default typesetting. Defaults can be overridden downstream with the exception of visibility.

Layers can be rendered invisible by tweaking the defaults. This should be possible in real time with GUI widgets or (hopefully) menu icons.

1. Create a Latex Style to encapsulate separate layers in their own markup. I'm using HTML's heading markups as a mental model for this.

2. Create parameters in the style to create unique names and a default attribute set for the enclosed text.

3. Create elements in the Lyx UI to allow usage of the functionality in lyx.

Right now, I'm not even considering part 3. If anybody's had experience creating custom styles, can you help with the following:

1. Is there a "visible" attribute to a standard Latex style element? (I'll probably know this in a few hours, but why not ask?)

2. Can a single style contain multiple variants (for instance, different typesetting available for a "paragraph" element)?

3. Going to need a way to "naturally" nest any additional fomatting INSIDE the layer markup. Is there a way or do I need to code this?

4. Is there a preferred language for coding LATEX/LYX modules? I'll probably work in tcl unless there's a preferred language.


Thanks for the read, I will be checking and (hopefully) updating this thread as the work proceeds.
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Creating a controllable text "Layer" in a master documen

Post by scottkosty »

Thanks for the update. It will be fun to follow along. You should know about two important resources: lyx-users@lists.lyx.org and lyx-devel@lists.lyx.org
That is where the LyX experts hang out. For LaTeX experts, this forum is the place.
Polaris96
Posts: 5
Joined: Thu Aug 15, 2013 8:55 pm

Creating a controllable text "Layer" in a master document

Post by Polaris96 »

Thanks very much, Scott. When I have time I'll mirror this there and hopefully render further work unnecessary. At the moment, though...

Took a quick look at the lyx note function. Too specific. It would take a lot of work to retask it.

Thought of fleshing out the "Part" element of a class sheet to allow toggling. This won't work because the Part structure is essentially linear and inline. I couldn't have, say "Part 1" arbitrarily popping up in any other Part. NotSoGood.

Then I found some reference to the comment package in tex http://www.ctan.org/tex-archive/macros/ ... ib/comment. This looks very promising. It even allows user defined environments (Layers, in potentia).

I'll be away for a while (like I said, I DO have a day job), but my direction now has been narrowed, at least at the LATEX level:

1. explore the limits of the comment package.

2. hopefully, change from a fully synthetic creation, to writing a wrapper so the comment package does the heavy lifting.

3. at present, the UI for lyx is still looking just as tough. Let's lick the process first, then worry about making it friendly to use.
Polaris96
Posts: 5
Joined: Thu Aug 15, 2013 8:55 pm

Creating a controllable text "Layer" in a master document

Post by Polaris96 »

ok, comment provides the exact type of visibility toggling I want. xcolor provides a nice (68 colour) palette. These packages are responding well and ready to be "wrapped"

But I also want control of the font. The fontspec pakg appears to be a good choice but I don't see it readily available in my OS (debian linux). I'm going to try manually installing it from CTAN and we'll have to see how that goes (very often when a standard distro drops a package it's because there are conflicts with other standard OS stuff. Hopefully this will not be the case here...)

After that, we'll design a simple command to control the layering. Right now, I'm thinking:

Code: Select all

\layer{$NAME,$COLOUR,$FONT, $VIS}
to declare the layer and

Code: Select all

\begin{$NAME}...\end{name}
More on that when I start writing the module file and sample page.

after $THAT, we'll start thinking about fitting it into lyx...
Post Reply