4

I am new to LyX, and am using v2.1.2 with the book class. In addition to help with my specific questions, I would appreciate any feedback if there is a better way to achieve my desired results. Sorry if this is overly long, I was not sure how to break it into smaller posts given the background information necessary to understanding the problems.

My ability to get this far was greatly aided by Create new paragraph style in LyX on this web site.

I have made several new environments based on 'quotation' to set notice, caution, and warning messages apart from normal paragraphs, to emphasize them in a user manual. These special paragraphs have wider margins, may have bold text, may have different color text, and will begin with a label of the type of message: 'Note:', 'Warning:', 'Caution:'. I would like to use a hanging indent so the label stands alone to the left of the paragraph:

      Note:  Efdfd gdgfdf dgdfd dfere dfere geef geeds etjlj gelj ekjld glegee
             ljkjlj ekek eskie ekeke.

I have moved stdlayouts.inc from the programs area (Windows) to the user area, duplicated the 'Quotation' style, and modified it into a new style 'Note' as shown below (similar styles for 'Caution' and 'Warning' have also been added but are not shown here):

Style Note
Category              MainText
Margin                Static
LatexType             Environment
LatexName             note
LabelString           "NOTE: "
NextNoIndent          1
LeftMargin            MMM
RightMargin           MMM
ParIndent             0
ParSkip               0
ItemSep               0
TopSep                0.5
BottomSep             0.5
ParSep                0.2
Align                 Block
AlignPossible         Block, Left, Right, Center
Font
    Series            Bold
    Color             Black
EndFont
HTMLTag               blockquote
HTMLItem              div
Preamble
\newenvironment{note}
    {\quotation\hangindent=2cm\color[rgb]{1,0.2,0.3}{NOTE: }}
    {\endquotation}
EndPreamble
End

The pdf output is very close to what I want. The wider margins, bold font, and color are all working, but the hanging indent is not. Also, the second 'note' paragraph is the same color as the following 'caution' paragraph rather than the color of the first 'note' paragraph.

'Note' and 'Caution' PDF Output:

'Note' pdf output

LyX code using 'Note' and 'Caution':

These safety-related terms appear in this manual: 
\begin{note}
Statements identify information that you should consider before moving
to the next instruction or choice. Statements identify information
that you should consider before moving to the next instruction or
choice. Statements identify information that you should consider before
moving to the next instruction or choice.

Statements identify information that you should consider before moving
to the next instruction or choice. Statements identify information
that you should consider before moving to the next instruction or
choice. Statements identify information that you should consider before
moving to the next instruction or choice.\end{note}
\begin{caution}
Statements identify conditions or practices that could result in damage
to the equipment, the software, or other property.\end{caution}

Question: In the 'note' style I tried to add a LabelString to use "Note: " as a prefix to the paragraph in the LyX display, so that it would not need to be typed in each time, but rather added automatically by selecting the 'note' style. This is not working (I am just guessing on how to do this). Is this possible, and if so, how? The environment code does do this correctly in the pdf output.

Thank you!

2
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Usually we post only a question for each thread, so I would suggest that you choose a main question to ask in this thread and then ask your other questions in different threads, each of them referencing your original question.
    – Pier Paolo
    Dec 4, 2014 at 20:58
  • @Pier Paolo - thank you, I will update in the next few minutes.
    – Zono
    Dec 4, 2014 at 21:24

1 Answer 1

0

With the info provided by scottkosty (Documentation on the arguments used when defining styles in an .inc file), I was able to figure out how to get the desired output on the LyX screen. The style code below was added to a user copy of stdlayouts.inc. The 'caution' style is just a variant of 'note', made easy by the use of the copystyle command.

Style Note
Category              MainText
Margin                Static
LatexType             Environment
LatexName             note
#   LabelIndent           MMM       # does not seem to do anything
LabelString           "NOTE:"
LabelType             Static
LabelSep              M
NextNoIndent          1
LeftMargin            MMMMMMMMM   # widens margins (decreases text area) of paragraph
RightMargin           MMMMMMMMM
ParIndent             0
ParSkip               0
ItemSep               0
TopSep                0.5
BottomSep             0.5
ParSep                0.3
Align                 Block
AlignPossible         Block, Left, Right, Center
Font
    Series            Bold
    Color             Black
EndFont
# html key-value pairs not yet changed to support this style
HTMLTag               blockquote
HTMLItem              div
Preamble
\newenvironment{note}
    {\quote\bf{NOTE: }}
    {\endquote}
EndPreamble
End

Style Caution
CopyStyle             "Note"
LatexName             caution
LabelString           "CAUTION:"
Font
    Series            Bold
    Color             Red
EndFont
# html key-value pairs not yet changed to support this style
HTMLTag               blockquote
HTMLItem              div
Preamble
\newenvironment{caution}
    {\quote\bf\color[rgb]{1,0.2,0.3}{CAUTION: }}
    {\endquote}
EndPreamble
End

Output on LyX screen:

'Note' appleanace on LyX screen

Output in PDF:

enter image description here

Unresolved Issues

I was not able to get hanging indent working, to get the PDF output looking like the LyX GUI screen shot. The '\hangindent=2cm' command did not seem to do anything. The results are not perfect, but are close enough for what I need.

The 'LabelIndent' key did not seem to work. Since it did not, I had to manually set the margins to look right using the longest label of the 3 I needed (Note, Caution, Warning). Again, not perfect, but close enough for what I need.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .