Sam Liddicott wrote:
* Ricardo Perrone wrote, On 21/08/09 04:05:
Hi,

[...]

You can mess with tie \fontsize{}{} command; insert this in your pre-amble:

\newcommand\sizetf[1]{\begingroup\fontsize{10.5}{12}\selectfont{#1}\endgroup}

then you can use the command

\sizetf{I'm in 10.5pt}

in ERT in your document.

(I wish Lyx supported adding per-document layouts and elements in the
same way that it supports adding Latex commands in the preamble)

Isn't that what layout modules are for ? Something like the following seems to work fine (I set the aspect to green in LyX to clearly differentiate from the normal text):
----------------
InsetLayout CharStyle:FontSize10.5
        LyxType               charstyle
        LabelString           FontSize10.5
        LatexType             command
        LatexName             SizeTenPointFive
        Font
          Color               green
          Size                normal
        EndFont
        Preamble
        
\newcommand\SizeTenPointFive[1]{\begingroup\fontsize{10.5}{12}\selectfont{#1}\endgroup}
        EndPreamble
End
----------------

I attach an example module with font sizes from 8 to 12.5 with step 0.5. It works fine for me on 1.6.3. Once it is copied to the layout folder (*), you reconfigure, close & reopen lyx, and add the "Font Size Styles" module in the Document->Settings, "Modules" tab. Apply and you automatically have those styles in "Edit->Text Styles" or better, in the right-click contextual menu.

However, I do not encourage the use of font size this way. Better is to use logical styles.

Best regards,

Olivier

(*) On windows, it is
C:\Documents and Settings\###?\Application Data\lyx16\layouts
where ### is the user name
on linux, it should be in the home folder, in something like .lyx16/layouts

#\DeclareLyXModule{Font Size Styles}
#DescriptionBegin
#Custom font sizes.
#DescriptionEnd

# Author : ORi (based on code by Sam Liddicott)

Format 11

InsetLayout CharStyle:FontSize8
        LyxType               charstyle
        LabelString           FontSize8
        LatexType             command
        LatexName             SizeEight
        Font
          Color               green
          Size                small
        EndFont
        Preamble
        
\newcommand\SizeEight[1]{\begingroup\fontsize{8}{9.5}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize8.5
        LyxType               charstyle
        LabelString           FontSize8.5
        LatexType             command
        LatexName             SizeEightPointFive
        Font
          Color               green
          Size                small
        EndFont
        Preamble
        
\newcommand\SizeEightPointFive[1]{\begingroup\fontsize{8.5}{10}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize9
        LyxType               charstyle
        LabelString           FontSize9
        LatexType             command
        LatexName             SizeNine
        Font
          Color               green
          Size                small
        EndFont
        Preamble
        
\newcommand\SizeNine[1]{\begingroup\fontsize{9}{10.5}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize9.5
        LyxType               charstyle
        LabelString           FontSize9.5
        LatexType             command
        LatexName             SizeNinePointFive
        Font
          Color               green
          Size                small
        EndFont
        Preamble
        
\newcommand\SizeNinePointFive[1]{\begingroup\fontsize{9.5}{11}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize10
        LyxType               charstyle
        LabelString           FontSize10
        LatexType             command
        LatexName             SizeTen
        Font
          Color               green
          Size                normal
        EndFont
        Preamble
        
\newcommand\SizeTen[1]{\begingroup\fontsize{10}{11.5}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize10.5
        LyxType               charstyle
        LabelString           FontSize10.5
        LatexType             command
        LatexName             SizeTenPointFive
        Font
          Color               green
          Size                normal
        EndFont
        Preamble
        
\newcommand\SizeTenPointFive[1]{\begingroup\fontsize{10.5}{12}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize11
        LyxType               charstyle
        LabelString           FontSize11
        LatexType             command
        LatexName             SizeEleven
        Font
          Color               green
          Size                normal
        EndFont
        Preamble
        
\newcommand\SizeEleven[1]{\begingroup\fontsize{11}{13}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize11.5
        LyxType               charstyle
        LabelString           FontSize11.5
        LatexType             command
        LatexName             SizeElevenPointFive
        Font
          Color               green
          Size                normal
        EndFont
        Preamble
        
\newcommand\SizeElevenPointFive[1]{\begingroup\fontsize{11.5}{13.5}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize12
        LyxType               charstyle
        LabelString           FontSize12
        LatexType             command
        LatexName             SizeTwelve
        Font
          Color               green
          Size                normal
        EndFont
        Preamble
        
\newcommand\SizeTwelve[1]{\begingroup\fontsize{12}{14}\selectfont{#1}\endgroup}
        EndPreamble
End

InsetLayout CharStyle:FontSize12.5
        LyxType               charstyle
        LabelString           FontSize12.5
        LatexType             command
        LatexName             SizeTwelvePointFive
        Font
          Color               green
          Size                large
        EndFont
        Preamble
        
\newcommand\SizeTwelvePointFive[1]{\begingroup\fontsize{12.5}{14.5}\selectfont{#1}\endgroup}
        EndPreamble
End

Reply via email to