On 12/31/19 3:11 PM, Hal Kierstead wrote:
>
>> On Dec 31, 2019, at 12:52 PM, Paul A. Rubin <parubi...@gmail.com> wrote:
>>
>> On 12/31/19 11:26 AM, Hal Kierstead wrote:
>>> All -
>>>
>>> I would like to display some text and math, and have a tag that I can 
>>> reference, something like in the attached files that I generated with LyX. 
>>> My efforts seem clumsy, and I was wondering if any one had a better idea.
>>>
>>> Thanks,
>>>
>>> Hal
>>>
>> Since you are using enumitem, with one tweak to the preamble (to get rid of 
>> a default colon) you can use the "Labeling" environment (the "List" tool bar 
>> button, one right of the button to insert itemized lists). The margins of 
>> the inset are not identical to what you have, but it might suffice. I've 
>> attached a hacked version of your file.
>>
>> Paul
>>
>> <DisplayedText.lyx>-- 
>> lyx-users mailing list
>> lyx-users@lists.lyx.org
>> http://lists.lyx.org/mailman/listinfo/lyx-users
> Thanks, Paul. I had thought of this, and I should be able to adjust the left 
> and right edges of the text to get what I want, but I could not figure out 
> how to do it with enumitem.
>
> I think my desired construct is one that others might find useful. For 
> instance I see it in textbooks.

Certainly the best way to do this is to define some environment with a
label, etc. and appropriate sorts of margins. I'm attaching a module I
wrote to do something similar. The right margin can be adjusted by
redefining \rightmargin within the list.

For enumitem, there's a very nice explanation of list parameters in the
docs, here:

   
http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/enumitem/enumitem.pdf

See p. 3. You can just do things like:

    \begin{description}[rightmargin = 1em]
        \item ....
    \end{description}

in LaTeX, of course. In LyX, you do Insert> Itemize Options on the first
item, and put "rightmargin = ..." into that inset. For one-off uses,
this would be fine.

To define a new list type, we can use enumitem like this:

\newlist{mydesc}{description}{1}
\setlist{mydesc}{rightmargin=1em}

This would act exactly like the regular description environment, but
with a right margin of 1em. You can add other modifiers to the setlist
command as you wish (e.g., font=\sffamily\bfseries to set the label font
to bold sans serif). And now we can do this in local layout, or in a module:

Style MyDesc
    CopyStyle description
    LatexName mydesc
    Premable
        \newlist{mydesc}{description}{1}
        \setlist{mydesc}{rightmargin=1em}
    EndPreamble
End

Riki





#\DeclareLyXModule{Formula}
#DescriptionBegin
#An environment for numbered formulas.
#DescriptionEnd

Format 64

Counter formula
        Within chapter
End

Counter thesis
        Within chapter
End

Style Formula
        Margin                First_Dynamic
        LatexType             Item_Environment
        LatexName             Formula
        NextNoIndent          1
        LabelSep              xxxxxx
        LeftMargin            MMM
        ParSkip               0.4
        ItemSep               0.2
        TopSep                0.7
        BottomSep             0.7
        ParSep                0.3
        Align                 Block
        AlignPossible         Block, Left
        LabelType             Static
        LabelCounter          formula
        LabelString           "(\arabic{formula})"
        LabelFont
                Shape               Up
                Series              Bold
        EndFont
        Preamble
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                % Formula module
                %
                \usepackage{calc}
                %\usepackage{ifthen}
                \newcounter{formula}
                \def\@rh@item{\refstepcounter{formula}\olditem}
                
\def\@rh@opt@item[#1]{\protected@edef\@currentlabel{#1}\olditem[#1]}
                \newenvironment{Formula}%
                {\begin{list}{\theformula}{%
                        \setlength{\labelwidth}{\leftmargin - \labelsep}%
                        \let\olditem=\item%
                        
\renewcommand{\item}{\@ifnextchar[\@rh@opt@item\@rh@item}%
                        \renewcommand{\makelabel}[1]{(##1)\hfil}}%
                }{\end{list}}
                \@ifpackageloaded{refstyle}{%
                        \newref{for}{%
                                refcmd    = {(\ref{#1})},
                                rngtxt    = \RSrngtxt,
                                lsttwotxt = \RSlsttwotxt,
                                lsttxt    = \RSlsttxt}}
                {}
                \@ifpackageloaded{prettyref}{%
                        \newrefformat{For}{(\ref{#1})}
                        \newrefformat{for}{(\ref{#1})}}
                {}
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        EndPreamble
        RefPrefix for
End

Style Formula_Restate
        DependsOn             Formula
        CopyStyle             Formula
        LabelType             Static
        LabelCounter          ""
        LabelString           "(REF)"
        Preamble
        EndPreamble
# Unfortunately, this becomes the argument to the enviroment,
# not to the item.
#       Argument 1
#               AutoInsert     1
#               LabelString   "Label"
#       EndArgument
End

Style Thesis
        Margin                First_Dynamic
        LatexType             Item_Environment
        LatexName             Thesis
        NextNoIndent          1
        LabelSep              xxxxxx
        LeftMargin            MMM
        ParSkip               0.4
        ItemSep               0.2
        TopSep                0.7
        BottomSep             0.7
        ParSep                0.3
        Align                 Block
        AlignPossible         Block, Left
        LabelType             Static
        LabelCounter          thesis
        LabelString           "Thesis \arabic{thesis}"
        LabelFont
                Shape               Up
                Series              Bold
        EndFont
        Preamble
                \usepackage{calc}
                %\usepackage{ifthen}
                \newcounter{thesis}
                \def\@rht@item{\refstepcounter{thesis}\olditem}
                
\def\@rht@opt@item[#1]{\protected@edef\@currentlabel{#1}\olditem[#1]}
                \newenvironment{Thesis}%
                {\begin{list}{\thethesis}{%
                        \setlength{\labelwidth}{\leftmargin - \labelsep}%
                        \let\olditem=\item%
                        
\renewcommand{\item}{\@ifnextchar[\@rht@opt@item\@rht@item}%
                        \renewcommand{\makelabel}[1]{\textbf{Thesis ##1}\hfil}}%
                }{\end{list}}
                \@ifpackageloaded{refstyle}
                {%
                        \newref{ths}{%
                                refcmd    = {Thesis \ref{#1}},
                                rngtxt    = \RSrngtxt,
                                lsttwotxt = \RSlsttwotxt,
                                lsttxt    = \RSlsttxt}}
                {}
                \@ifpackageloaded{prettyref}{%
                        \newrefformat{ths}{Thesis \ref{#1}}}
                {}
        EndPreamble
        RefPrefix ths
End
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to