Manveru wrote:
I do not have 1.6 yet... but I do not understand how LyX understands how to
handle these new commands? From my understanding these go only to preamble
of document, but how to add these to some buttons on toolbar for example?
This layout module is simply adding the definitions to the preamble.
Then, when you type in a formula \erf for instance, it will not be
interpreted by LyX (unless you use preview-latex stuff). But when
generating the pdf, they will be correctly interpreted as functions
(i.e. not in italic, and with a small space afterwards).
The advantage of having them in a layout module is that you do not have
to add them in a preamble by hand. Just add the module to the document
settings, as described in http://wiki.lyx.org/LyX/NewInLyX16#toc4 .
Of course if someone has any ideas to provide more functionality, any
idea is welcome (that's the reason for posting the module).
You can also have layouts that will create text styles or environments,
and those will appear in some menus automatically. That's how I have
implemented my "filename" and "code" text styles. See the
"logicalmkup.module" file for an example or my module below.
When I add my "customstyles.module" to the document settings, two
entries appear in the "Edit->Text Style" menu for using them. And when I
use them, LyX correctly change the text style accordingly. Here it is
for reference:
-------------------------------------------------------------------
#\DeclareLyXModule{Custom Styles}
#DescriptionBegin
#Custom character styles for code, filename.
#DescriptionEnd
# Author : Olivier Ripoll (based on layout by Martin Vermeer)
Format 7
InsetLayout CharStyle:Filename
LyxType charstyle
LabelString filename
LatexType command
LatexName filename
Font
Series Bold
Family Typewriter
EndFont
Preamble
\newcommand{\filename}[1]{\texttt{\textbf{#1}}}
EndPreamble
End
InsetLayout CharStyle:Code
LyxType charstyle
LabelString code
LatexType command
LatexName code
Font
Family Typewriter
EndFont
Preamble
\newcommand{\code}[1]{\texttt{#1}}
EndPreamble
End
-------------------------------------------------------------------
Note that I am pretty sure you can create shortcuts for accessing the
styles using what is described on the wiki:
http://wiki.lyx.org/Tips/KeyboardShortcutForCharacterStyles
Best regards,
Olivier
2008/8/19 Olivier Ripoll <[EMAIL PROTECTED]>
Hi,
I just wanted to share a simple and probably imperfect layout module for
LyX 1.6. I do not know much about LaTeX, so I used the examples provided
with LyX and google to create this file. I called it
"moremathsfunctions.module" (it should be placed in the "layouts" folder in
the lyx 1.6 preference folder of your home directory -- in "Application
Data" for windows users), and here is the content (between the dashed lines,
so people can comment on the code):
------------------------------------------------------------------------
#\DeclareLyXModule{More Maths Functions}
#DescriptionBegin
#Additional functions: erf, erfc, sinc, sgn , missing hyperbolic & inverse
hyperbolic functions,
#Fourier transform & inverse, logarithms in base 10 and 2, floor/ceil
(letters and mathematical
#notation).
#DescriptionEnd
# Author : Olivier Ripoll
Format 7
Requires amsmath,mathrsfs
AddToPreamble
\DeclareMathOperator{\sinc}{sinc}
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\erf}{erf}
\DeclareMathOperator{\erfc}{erfc}
\DeclareMathOperator{\FT}{\mathscr{F}}
\DeclareMathOperator{\iFT}{\mathscr{F}^{-1}}
\DeclareMathOperator{\logten}{log_{10}}
\DeclareMathOperator{\logtwo}{log_2}
\DeclareMathOperator{\sech}{sech}
\DeclareMathOperator{\csch}{csch}
\DeclareMathOperator{\arsinh}{arsinh}
\DeclareMathOperator{\arcosh}{arcosh}
\DeclareMathOperator{\artanh}{artanh}
\DeclareMathOperator{\arcoth}{arcoth}
\DeclareMathOperator{\arsech}{arsech}
\DeclareMathOperator{\arcsch}{arcsch}
\newcommand{\Floor}[1]
{\left\lfloor {#1} \right\rfloor}
\DeclareMathOperator{\floor}{floor}
\newcommand{\Ceil}[1]
{\left\lceil #1 \right\rceil}
\DeclareMathOperator{\ceil}{ceil}
EndPreamble
------------------------------------------------------------------------
As the description says, this module simply defines several useful math
functions that are not available by default (I hope I did not overwrite
existing LaTeX stuff). There are two versions of the "floor" and "ceil"
functions, the one with a capital letter must be followed by \{xxx} where
xxx is the number to which it is applied. It provides an aspect like in
http://en.wikipedia.org/wiki/Floor_function
I used http://en.wikipedia.org/wiki/List_of_mathematical_functions as a
reference for the functions I added. And before someone says so, Fourier
transform and its inverse are not functions, but I do not care ;-)
I hope this can be helpful to someone. I like this layout module feature a
lot, I created another one with custom char styles for filenames and code,
based on Martin Vermeer's "logicalmkup.module".
Small question: should I change the "Format 7" to "Format 8" ?
Best regards,
Olivier
PS: be careful, some lines are wrapped by the mail agent in the
description.