Re: How to define "fragments" within LyX 2.2.1?
On 08/11/2016 07:07 PM, Richard Heck wrote: > On 08/11/2016 04:53 PM, Bernt Lie wrote: >> >> I have used SWP a lot in the past, and really like that product >> (despite some limitations). They support “fragments” which is really >> great: >> >> ·Mark any part of a document, and save this marked part as a >> “fragment” in a file of a given name. >> >> ·Then call back this fragment by typing Ctrl+ fragment name >> at any time (v 5.5). (Use of the Ctrl key makes it slightly complex >> to type, so there may be better ways). >> >> ·Examples of fragments could be (I) horizontal fill + math >> \blacktriangle (e.g named endex – end of example) (ii) a floating >> table with center table (e.g, mytab), (iii) similar for figures (e.g, >> myfig), (iv) a symbol for scaled variables (e.g, scaled), (v) an >> empty data list object set to the Python language, numbered lines on >> the left side with smallest font using typewriter font (e.g, >> mypython), etc., etc. >> >> In summary: fragments are great – very useful, and very intuitive to >> use! Sorely missed. >> > > You can approximate this behavior by copying the fragment to a LyX > file and then using Insert> File> LyX Document to insert it. You can > bind the file-insert command to a keystroke to make it easier to open > the relevant dialog, if you wish. And if you have some file you want > to insert a lot, you can bind a key to something like "file-insert > /path/to/myfile.lyx". Though, at the moment, that does not seem to be > working for me. Hmm. I'll investigate. No, it does work. I was foolishly mistyping the filename. Over and over. Richard
Re: How to define "fragments" within LyX 2.2.1?
On 08/11/2016 04:53 PM, Bernt Lie wrote: > > I have used SWP a lot in the past, and really like that product > (despite some limitations). They support “fragments” which is really > great: > > ·Mark any part of a document, and save this marked part as a > “fragment” in a file of a given name. > > ·Then call back this fragment by typing Ctrl+ fragment name at > any time (v 5.5). (Use of the Ctrl key makes it slightly complex to > type, so there may be better ways). > > ·Examples of fragments could be (I) horizontal fill + math > \blacktriangle (e.g named endex – end of example) (ii) a floating > table with center table (e.g, mytab), (iii) similar for figures (e.g, > myfig), (iv) a symbol for scaled variables (e.g, scaled), (v) an empty > data list object set to the Python language, numbered lines on the > left side with smallest font using typewriter font (e.g, mypython), > etc., etc. > > In summary: fragments are great – very useful, and very intuitive to > use! Sorely missed. > You can approximate this behavior by copying the fragment to a LyX file and then using Insert> File> LyX Document to insert it. You can bind the file-insert command to a keystroke to make it easier to open the relevant dialog, if you wish. And if you have some file you want to insert a lot, you can bind a key to something like "file-insert /path/to/myfile.lyx". Though, at the moment, that does not seem to be working for me. Hmm. I'll investigate. For short things, it's maybe easier to define a shortcut, as someone else explained, using command-sequence. These seem to be like "snippets" in other programs. I've never really used them myself, but I can see why someone might like to do so. To be honest, though, in LaTeX, this sort of "cut and paste" behavior always seems wrong to me: If there's something you want to insert a lot, especially in some regular way, it is best to define a command for it. Then you have more control over it. E.g., you could change all instances of it by re-defining the command. This seems especially true when it will be part of every environment of a certain kind. Note that LyX actually tries to encourage this "semantic" way of thinking. It would be nice if LyX allowed for "text macros" the way it allows for "math macros". That would make this sort of thing much easier. There's a long-standing wish for this Richard
RE: How to define "fragments" within LyX 2.2.1?
I have used SWP a lot in the past, and really like that product (despite some limitations). They support “fragments” which is really great: ·Mark any part of a document, and save this marked part as a “fragment” in a file of a given name. ·Then call back this fragment by typing Ctrl+ fragment name at any time (v 5.5). (Use of the Ctrl key makes it slightly complex to type, so there may be better ways). ·Examples of fragments could be (I) horizontal fill + math \blacktriangle (e.g named endex – end of example) (ii) a floating table with center table (e.g, mytab), (iii) similar for figures (e.g, myfig), (iv) a symbol for scaled variables (e.g, scaled), (v) an empty data list object set to the Python language, numbered lines on the left side with smallest font using typewriter font (e.g, mypython), etc., etc. In summary: fragments are great – very useful, and very intuitive to use! Sorely missed. -Bernt From: Richard Heck<mailto:rgh...@lyx.org> Sent: Thursday, August 11, 2016 21:08 To: Bernt Lie<mailto:bernt@hit.no>; lyx-users@lists.lyx.org<mailto:lyx-users@lists.lyx.org> Subject: Re: How to define "fragments" within LyX 2.2.1? On 08/11/2016 07:43 AM, Bernt Lie wrote: Preliminaries: I use Windows 10 with LyX 2.2.1. I need to have some symbol to close Examples. Here is what I do: · I change the first paragraph in an example from Standard to Example. This allows me to number the example, and I can insert a marker/label so that I can refer to the example. · I choose to let the subsequent paragraphs within the example be standard paragraphs, so that I am not limited by the layout constraints within theorem-like elements. What is the problem here? · I then need some symbol to indicate the end of an example (I would need that anyway, because LyX seems to typeset example “body text” in roman font, contrary to the default of “old LaTeX” – personally, I welcome this, because example text is often lengthy, and it looks bad with a lengthy text in italic...) · OK – the symbol I have chosen to close the example is: “Horizontal fill” + math symbol “\blacktriangle”. This will push a black (upward pointing) triangle to the right margin. The triangle is supposed to point into the example... · Is there a way that I can give a *name* to this combination of “Horizontal fill” + “black triangle”, so that I can easily insert it? I’d like to call it “endex” (end-of-example), or something like that. How can I insert this “user defined” combination (“fragment”) into the LyX document with a simple keyboard short-cut? Two answers. To do this the way you describe, simply do it the way you could do it in LaTeX: \newcommand\endex{\hfill$\blacktriangle$} Then put "\endex" in TeX code where you need it. A better way to do it would be to define your own environment, one that ended this way. To do so, I'd suggest mimicking or modifying the proof environment. There's an issue about how the closing symbol is handled when the line is long, one you'll likely see if you do this the first way. The proof environment contains code to handle that, which you can simply adapt. Obviously, that means getting yourself into the LaTeX code, but that's inevitable if you want to do this kind of customization. Richard PS It's possible there are LaTeX packages that would help with this. You might try asking at stack exchange.
Re: How to define "fragments" within LyX 2.2.1?
On 08/11/2016 07:43 AM, Bernt Lie wrote: > > Preliminaries: I use Windows 10 with LyX 2.2.1. > > > > I need to have some symbol to close Examples. Here is what I do: > > · I change the first paragraph in an example from Standard to > Example. This allows me to number the example, and I can insert a > marker/label so that I can refer to the example. > > · I choose to let the subsequent paragraphs within the example > be standard paragraphs, so that I am not limited by the layout > constraints within theorem-like elements. > What is the problem here? > · I then need some symbol to indicate the end of an example (I > would need that anyway, because LyX seems to typeset example “body > text” in roman font, contrary to the default of “old LaTeX” – > personally, I welcome this, because example text is often lengthy, and > it looks bad with a lengthy text in italic...) > > · OK – the symbol I have chosen to close the example is: > “Horizontal fill” + math symbol “\blacktriangle”. This will push a > black (upward pointing) triangle to the right margin. The triangle is > supposed to point into the example... > > · Is there a way that I can give a **name** to this > combination of “Horizontal fill” + “black triangle”, so that I can > easily insert it? I’d like to call it “endex” (end-of-example), or > something like that. How can I insert this “user defined” combination > (“fragment”) into the LyX document with a simple keyboard short-cut? > Two answers. To do this the way you describe, simply do it the way you could do it in LaTeX: \newcommand\endex{\hfill$\blacktriangle$} Then put "\endex" in TeX code where you need it. A better way to do it would be to define your own environment, one that ended this way. To do so, I'd suggest mimicking or modifying the proof environment. There's an issue about how the closing symbol is handled when the line is long, one you'll likely see if you do this the first way. The proof environment contains code to handle that, which you can simply adapt. Obviously, that means getting yourself into the LaTeX code, but that's inevitable if you want to do this kind of customization. Richard PS It's possible there are LaTeX packages that would help with this. You might try asking at stack exchange.
Re: How to define "fragments" within LyX 2.2.1?
On Thu, Aug 11, 2016 at 11:43:49AM +, Bernt Lie wrote: > Preliminaries: I use Windows 10 with LyX 2.2.1. > > I need to have some symbol to close Examples. Here is what I do: > > * I change the first paragraph in an example from Standard to > Example. This allows me to number the example, and I can insert a > marker/label so that I can refer to the example. > > * I choose to let the subsequent paragraphs within the example be > standard paragraphs, so that I am not limited by the layout constraints > within theorem-like elements. > > * I then need some symbol to indicate the end of an example (I would > need that anyway, because LyX seems to typeset example "body text" in roman > font, contrary to the default of "old LaTeX" - personally, I welcome this, > because example text is often lengthy, and it looks bad with a lengthy text > in italic...) > > * OK - the symbol I have chosen to close the example is: "Horizontal > fill" + math symbol "\blacktriangle". This will push a black (upward > pointing) triangle to the right margin. The triangle is supposed to point > into the example... > > * Is there a way that I can give a *name* to this combination of > "Horizontal fill" + "black triangle", so that I can easily insert it? I'd > like to call it "endex" (end-of-example), or something like that. How can I > insert this "user defined" combination ("fragment") into the LyX document > with a simple keyboard short-cut? This link might be useful for figuring out how to automate things that you usually do with the GUI: http://tex.stackexchange.com/questions/208510/lyx-commands-to-insert-wysiwyg-horizontal-line-for-keyboard-shortcut/208531#208531 Then you can do them all together with "command-sequence". Scott signature.asc Description: PGP signature