Re: Creating a tree with math in LyX

2018-03-31 Thread Joel Kulesza
On Sat, Mar 31, 2018 at 11:37 AM, Scott Kostyshak  wrote:

>
> I think I will go for this workaround instead of the TiKZ path for now.
> I would like to learn TiKZ, but not until I want to dedicate some time
> to learning it correctly.


Definitely use what works and feels most convenient.

However, I'd caution you against waiting to play with TikZ until "learning
it correctly".  It has a truly immense feature set.  I'm continually
learning about new features (I found "spy" not too long ago, which was
nearly mind blowing).  Almost every time I use TikZ I learn a better or
more efficient way to do something, that I wish I would have known
previously, but in each case I ended up with a graphic I was happy with and
file away that knowledge for next time.

- Joel


Re: Creating a tree with math in LyX

2018-03-31 Thread Scott Kostyshak
On Sat, Mar 31, 2018 at 04:30:43PM +, racoon wrote:

> In the preamble:

> An example diagram (I added an instant preview around it):

Thanks, That example looks nice. This helped me realize that the reason
I need the \protect is only because of the equals sign, not the math.
Yours uses math but because you don't use an equals sign, there is no
error. This helped me realize that I can use a workaround of
$\overset{}{=}$, for which I don't even need ERT.

I think I will go for this workaround instead of the TiKZ path for now.
I would like to learn TiKZ, but not until I want to dedicate some time
to learning it correctly.

Attached is my previous example changed to use the workaround mentioned
above.

Thanks to all for your help!

Scott


tree_math.22.lyx
Description: application/lyx


signature.asc
Description: PGP signature


Re: Creating a tree with math in LyX

2018-03-31 Thread racoon

On 31.03.2018 00:35, Scott Kostyshak wrote:

I would like to make a simple tree that uses math. The current way I do
it is to use the linguistics module, which gives access to the forest
package. Then I go to Insert > custom insets > Structure tree. I then
wrap the math I want to write in \protect. Attached is an example of
what I'm currently doing. It works, but I don't like writing out
\protect, and I have the feeling I'm asking the forest package to do
something it was not meant to do (include math).

Does someone recommend a different way?


I was in need of a decision tree diagram and found it rather hard to get 
a satisfactory result. Maybe something of this is helpful to you.


In the preamble:

\forestset{
  declare toks={elo}{},
my label/.style={
edge label={node[midway,above,text width=1.7cm,align=left]{#1}}
},
decision tree/.style={
for tree={
grow=east,
minimum size=2pt,
inner sep=2pt,
parent anchor=east,
child anchor=west,
l sep+=20mm,
s sep+=3mm,
edge path'={(!u.parent anchor) -- ([xshift=-18mm].child 
anchor)\forestove{elo} -- (.child anchor)},

}
}
}

An example diagram (I added an instant preview around it):

{\small
\begin{forest} decision tree
[,label=$n_0$,draw
  [,label=$n_3$,draw ,my label={$s_5,s_6$}
[$o_6$, my label=$s_6(n_3)$]
[$o_5$, my label=$s_5(n_3)$]
  ]
  [,label=$n_2$,draw, my label={$s_3,s_4$}
[$o_4$, my label=$s_4(n_2)$]
[$o_3$, my label=$s_3(n_2)$]
  ]
  [,label=$n_1$,draw, my label={$s_1,s_2$}
[$o_2$, my label=$s_2(n_1)$]
[$o_1$, my label=$s_1(n_1)$]
  ]
]
\end{forest}}



Re: Creating a tree with math in LyX

2018-03-31 Thread Rich Shepard

On Sat, 31 Mar 2018, Joel Kulesza wrote:


Plenty of people do.


Joel,

  I was referring, semi-seriously, to LyX users.


One interesting trait I've identified with PSTricks users: they love it!
Almost to a fault. Nearly every time I Google for how to do something with
TikZ, I always see a PSTricks user has provided an answer on how to do it
their way even though the question relates specifically to TikZ.


  That's common. I used to ask for help with an awk script and had responses
using perl, lua, haskell, and other non-awk responses.


TikZ can do this too.  Both tools have comparable capabilities.


  I assumed this to be the case.

Regards,

Rich


Re: Creating a tree with math in LyX

2018-03-31 Thread Joel Kulesza
On Sat, Mar 31, 2018 at 6:40 AM, Rich Shepard 
wrote:

> On 03/30/2018 06:35 PM, Scott Kostyshak wrote:
>
> Does someone recommend a different way?
>>
>
>   Just out of curiosity, does anyone but me use PSTricks for creating
> vector
> graphics?
>

Plenty of people do.

One interesting trait I've identified with PSTricks users: they love it!
Almost to a fault.  Nearly every time I Google for how to do something with
TikZ, I always see a PSTricks user has provided an answer on how to do it
their way even though the question relates specifically to TikZ.


>   Several years ago I created a scannable form with PSTricks and was able
> to
> adjust each component with very fine (sub-millimeter) resolution so the
> filled boxes were correctly seen by the scanner.
>

TikZ can do this too.  Both tools have comparable capabilities.


>   It does involve writing code but I've yet to find a situation where
> PSTricks didn't produce precision output fully compativle with LaTeX/LyX.
>

These are two different technologies (PSTricks/TikZ vs LyX/LaTeX, where
LaTeX is taken *very* loosely) intended for two different purposes.
Besides, LaTeX involves writing code, so working with TikZ, PSTricks, etc.
is a natural extension.

- Joel


Re: Creating a tree with math in LyX

2018-03-31 Thread Rich Shepard

On 03/30/2018 06:35 PM, Scott Kostyshak wrote:


Does someone recommend a different way?


  Just out of curiosity, does anyone but me use PSTricks for creating vector
graphics?

  Several years ago I created a scannable form with PSTricks and was able to
adjust each component with very fine (sub-millimeter) resolution so the
filled boxes were correctly seen by the scanner.

  It does involve writing code but I've yet to find a situation where
PSTricks didn't produce precision output fully compativle with LaTeX/LyX.

  Just my $0.02's worth. With open source we have a plethora of options,
sometimes too many. :-)

Carpe weekend,

Rich



Re: Creating a tree with math in LyX

2018-03-30 Thread Scott Kostyshak
On Fri, Mar 30, 2018 at 11:51:54PM +, Paul A. Rubin wrote:
> On 03/30/2018 06:35 PM, Scott Kostyshak wrote:
> > I would like to make a simple tree that uses math. The current way I do
> > it is to use the linguistics module, which gives access to the forest
> > package. Then I go to Insert > custom insets > Structure tree. I then
> > wrap the math I want to write in \protect. Attached is an example of
> > what I'm currently doing. It works, but I don't like writing out
> > \protect, and I have the feeling I'm asking the forest package to do
> > something it was not meant to do (include math).
> > 
> > Does someone recommend a different way?
> > 
> > Thanks,
> > 
> > Scott
> I'm also a fan of PGF/TiKZ. If you want to draw the diagrams using a drawing
> program, Inkscape can export a .tikz file, which you can then include in
> your LyX document. So can several other programs (Wikipedia page
> ).

Thanks. Perhaps then I would create a simple macro based on TiKZ. The
reason I want a simple macro is that it is for lecture notes and I use
these trees a lot, so want to easily create them.

> If by any chance you're an R user, you might consider using something like
> the DiagrammeR package to generate the diagrams and the tikzDevice package
> to output the diagram to a .tikz file.

I am and did not know about that package. Cool!

Thanks, Paul.

Scott


signature.asc
Description: PGP signature


Re: Creating a tree with math in LyX

2018-03-30 Thread Scott Kostyshak
On Fri, Mar 30, 2018 at 11:21:29PM +, Joel Kulesza wrote:

> also \usepackage{standalone} so that they inherit the parent document
> style, font, etc. settings when rendered out via LyX.

Cool package. I didn't know about that one.

> I find this approach gives me the fine-grained control I need/want while
> reducing repetition in the preamble.  Note that the preamble can also be
> included in the individual standalone .tikz.tex files to make sure
> everything is kept synchronized.
> 
> Crude demonstration attached.

Nice approach. I will take a look at this.

Thank you for your neat example.

Scott


signature.asc
Description: PGP signature


Re: Creating a tree with math in LyX

2018-03-30 Thread Paul A. Rubin

On 03/30/2018 06:35 PM, Scott Kostyshak wrote:

I would like to make a simple tree that uses math. The current way I do
it is to use the linguistics module, which gives access to the forest
package. Then I go to Insert > custom insets > Structure tree. I then
wrap the math I want to write in \protect. Attached is an example of
what I'm currently doing. It works, but I don't like writing out
\protect, and I have the feeling I'm asking the forest package to do
something it was not meant to do (include math).

Does someone recommend a different way?

Thanks,

Scott
I'm also a fan of PGF/TiKZ. If you want to draw the diagrams using a 
drawing program, Inkscape can export a .tikz file, which you can then 
include in your LyX document. So can several other programs (Wikipedia 
page ).


If by any chance you're an R user, you might consider using something 
like the DiagrammeR package to generate the diagrams and the tikzDevice 
package to output the diagram to a .tikz file.


Paul



Re: Creating a tree with math in LyX

2018-03-30 Thread Joel Kulesza
On Fri, Mar 30, 2018 at 5:02 PM, Scott Kostyshak  wrote:

> On Fri, Mar 30, 2018 at 04:55:10PM -0600, Joel Kulesza wrote:
> > On Fri, Mar 30, 2018 at 4:35 PM, Scott Kostyshak 
> wrote:
> >
> > > I would like to make a simple tree that uses math. The current way I do
> > > it is to use the linguistics module, which gives access to the forest
> > > package. Then I go to Insert > custom insets > Structure tree. I then
> > > wrap the math I want to write in \protect. Attached is an example of
> > > what I'm currently doing. It works, but I don't like writing out
> > > \protect, and I have the feeling I'm asking the forest package to do
> > > something it was not meant to do (include math).
> > >
> > > Does someone recommend a different way?
> > >
> >
> > I'm a fan of TikZ.
> >
> > http://www.texample.net/tikz/examples/feature/trees/
>
> Do you write out the TikZ each time? Or did you make an inset or macro
> that makes it quicker?
>
> I will be making several of these small trees. I can just copy paste the
> code each time and it is not so much trouble, but I'm curious if you
> have a smoother setup than that.


My workflow is to put global style definitions, etc. into a preamble.tex
file that I \input within LyX's Document Settings.  Or, if minimal, I
include them directly in the LyX file.

I then create the graphics as individual .tex files (usually
image_name.tikz.tex) that I then include as a Child Document in LyX.
The image_name.tikz.tex
are fully renderable files that I work with independently (these days, with
vimtex and Skim) while I tweak everything to my liking.  Because of this, I
also \usepackage{standalone} so that they inherit the parent document
style, font, etc. settings when rendered out via LyX.

I find this approach gives me the fine-grained control I need/want while
reducing repetition in the preamble.  Note that the preamble can also be
included in the individual standalone .tikz.tex files to make sure
everything is kept synchronized.

Crude demonstration attached.

- Joel


tikz_mwe.lyx
Description: Binary data


icon_magnifying_glass.tikz.tex
Description: Binary data


test1.tikz.tex
Description: Binary data


Re: Creating a tree with math in LyX

2018-03-30 Thread Scott Kostyshak
On Fri, Mar 30, 2018 at 04:55:10PM -0600, Joel Kulesza wrote:
> On Fri, Mar 30, 2018 at 4:35 PM, Scott Kostyshak  wrote:
> 
> > I would like to make a simple tree that uses math. The current way I do
> > it is to use the linguistics module, which gives access to the forest
> > package. Then I go to Insert > custom insets > Structure tree. I then
> > wrap the math I want to write in \protect. Attached is an example of
> > what I'm currently doing. It works, but I don't like writing out
> > \protect, and I have the feeling I'm asking the forest package to do
> > something it was not meant to do (include math).
> >
> > Does someone recommend a different way?
> >
> 
> I'm a fan of TikZ.
> 
> http://www.texample.net/tikz/examples/feature/trees/

Do you write out the TikZ each time? Or did you make an inset or macro
that makes it quicker?

I will be making several of these small trees. I can just copy paste the
code each time and it is not so much trouble, but I'm curious if you
have a smoother setup than that.

Scott


signature.asc
Description: PGP signature


Re: Creating a tree with math in LyX

2018-03-30 Thread Joel Kulesza
On Fri, Mar 30, 2018 at 4:35 PM, Scott Kostyshak  wrote:

> I would like to make a simple tree that uses math. The current way I do
> it is to use the linguistics module, which gives access to the forest
> package. Then I go to Insert > custom insets > Structure tree. I then
> wrap the math I want to write in \protect. Attached is an example of
> what I'm currently doing. It works, but I don't like writing out
> \protect, and I have the feeling I'm asking the forest package to do
> something it was not meant to do (include math).
>
> Does someone recommend a different way?
>

I'm a fan of TikZ.

http://www.texample.net/tikz/examples/feature/trees/

- Joel


Creating a tree with math in LyX

2018-03-30 Thread Scott Kostyshak
I would like to make a simple tree that uses math. The current way I do
it is to use the linguistics module, which gives access to the forest
package. Then I go to Insert > custom insets > Structure tree. I then
wrap the math I want to write in \protect. Attached is an example of
what I'm currently doing. It works, but I don't like writing out
\protect, and I have the feeling I'm asking the forest package to do
something it was not meant to do (include math).

Does someone recommend a different way?

Thanks,

Scott


tree_math.22.lyx
Description: application/lyx


signature.asc
Description: PGP signature