Hi,

I'm new to the lists, and relatively new to lyx and latex. I'm trying to set up a module that allows me to have a new Character style inset for entering Hebrew and polytonic Greek in Lyx, and processing everything with XeTex.

My situation is:
* I have successfully set up Lyx (1.6.1) on my Mac, and I am able to typeset documents with XeTex.

*I'm able to typeset the languages I need using ERT to specify fonts that have all the characters I need, but for various reasons I'm interested in avoiding ERT for the languages if possible.

*Here is the preamble I'm using in the document settings, which has been working so far:

\usepackage{fontspec}%
\setromanfont[Mapping=tex-text]{Garamond}%
\setsansfont[Mapping=tex-text]{Gill Sans}%
\setmonofont[Mapping=tex-text]{Courier New}%
\usepackage{xunicode}
\usepackage{xltxtra}

*Here is the module I've hacked together thus far.

#\DeclareLyXModule{XeTeX-Hebrew and Greek}
#DescriptionBegin
#This module is an attempt to make basic Hebrew and Greek text styles available for use with lyx and xetex. It requires lyx to be set up to use xetex, either in the document preamble or as described on the lyx wiki at http://wiki.lyx.org/Mac/XeTeX. #The module only uses Lucida Grande to typeset the Hebrew and Greek. At this point, the actual module file will have to be changed any time a change in font is necessary.
#DescriptionEnd

#Author: Me

Format 11

InsetLayout CharStyle:Greek
        LyxType               charstyle
        LabelString           greek
        LatexType             command
        LatexName             grk
        Preamble
         \newfontfamily{\G}{Lucida Grande}
         \newcommand{\grk}[1]{\G #1}
        EndPreamble
End

InsetLayout CharStyle:Hebrew
        LyxType               charstyle
        LabelString           hebrew
        LatexType             command
        LatexName             heb
        Preamble
        \newfontfamily{\H}{Lucida Grande}
        \newcommand{\heb}[1]{\H #1}
        EndPreamble
End

The LaTeX in the preamble sections above works perfectly for ERT if I copy it directly into the Document Settings ----> LaTeX Preamble.

I can get the module to show up in Lyx, and the insets seem to be working as planned in Lyx. However, as soon as I try to typeset the document using the insets for the language, I get the following error:

Undefined control sequence
 \newfontfamily
{\G}{Lucida Grande}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

LaTeX Error:  Missing \begin{document}.
 \newfontfamily{\G}{L
ucida Grande}
You're in trouble here. Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.

As I mentioned above, the exact same LaTeX code does exactly what I want when placed directly in the preamble and used with ERT.

I know that I'm overlooking something simple, but I can't seem to make any more progress here. Any help would be greatly appreciated.

I've hacked out a couple of other modules that work fine, but this one is beating me about the head and shoulders. My situation is not really desperate, since I can always fall back on the ERT, but it's more about winning now than anything.

Thanks for your time,

Reply via email to