Re: XeTeX - Load packages before fontspec

2014-06-13 Thread Michael Dean Pugh
I can see a very distinct reason for wanting to be able to modify the LyX-
generated preamble directly (without having to use a separate editor).  I'm 
using MathTime Professional II fonts and I want to use it in conjunction 
with the bm package so that I have access to the bm versions of the \bm and 
\hm modifiers.  In order for this to work, \usepackage{bm} _must_follow_ 
\usepackage{mtpro2} and with LyX generating \usepackae{bm} in its own 
preamble, the second \usepackage{bm} in my preamble is rendered useless.  I 
see this as much more of a hindrance than a feature. 



Re: XeTeX - Load packages before fontspec

2014-06-13 Thread Michael Dean Pugh
I can see a very distinct reason for wanting to be able to modify the LyX-
generated preamble directly (without having to use a separate editor).  I'm 
using MathTime Professional II fonts and I want to use it in conjunction 
with the bm package so that I have access to the bm versions of the \bm and 
\hm modifiers.  In order for this to work, \usepackage{bm} _must_follow_ 
\usepackage{mtpro2} and with LyX generating \usepackae{bm} in its own 
preamble, the second \usepackage{bm} in my preamble is rendered useless.  I 
see this as much more of a hindrance than a feature. 



Re: XeTeX - Load packages before fontspec

2014-06-13 Thread Michael Dean Pugh
I can see a very distinct reason for wanting to be able to modify the LyX-
generated preamble directly (without having to use a separate editor).  I'm 
using MathTime Professional II fonts and I want to use it in conjunction 
with the bm package so that I have access to the bm versions of the \bm and 
\hm modifiers.  In order for this to work, \usepackage{bm} _must_follow_ 
\usepackage{mtpro2} and with LyX generating \usepackae{bm} in its own 
preamble, the second \usepackage{bm} in my preamble is rendered useless.  I 
see this as much more of a hindrance than a feature. 



Re: XeTeX - Load packages before fontspec

2011-10-09 Thread Guenter Milde
On 2011-10-08, PhilipPirrip wrote:
 On 10/07/2011 08:17 AM, Guenter Milde wrote:
   Custom LaTeX code before LyX-generated preamble:
+-+
| \usepackage[put]{mathdesign}|
| |
+-+

 May I object! ;)

Defeated. This was an *example* for a *custom* user written pe-preamble.

This specific example loads a package that is not auto-loaded by LyX, so
there is no danger of an option clash. It is put in the pre-preamble to
ensure it is loaded before the auto-loaded packages.

If the user wants to add options to a LyX-auto-loaded package, then this
could/should be done with \PassOptionsToPackage in the pre-preamble, but
without \usepackage command.

 Please always consider calling \usepackage in two parts, especially in
 LyX generated code: to allow for the possibility of adding more options
 to the packages called. (calling \usepackage with options twice isn't
 allowed)

Acutally, repeated \usepackages with a *different option set* is not
allowed. This is because the second \usepackage is ignored and hence the
different options are ignored too.

However, as the minimal example

\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign}
\usepackage{mathdesign}
\PassOptionsToPackage{greekuppercase=italicized}{mathdesign}
\usepackage{mathdesign}

\begin{document}
$\Gamma$
\end{document}

shows, \PassOptionsToPackage after \usepackage is silently ignored. 
I.e. if LyX were to use it, this would not prevent the error but only the
error detection.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-09 Thread PhilipPirrip

On 10/09/2011 05:45 PM, Guenter Milde wrote:


\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign}
\usepackage{mathdesign}
\PassOptionsToPackage{greekuppercase=italicized}{mathdesign}
\usepackage{mathdesign}

\begin{document}
$\Gamma$
\end{document}

shows, \PassOptionsToPackage after \usepackage is silently ignored.
I.e. if LyX were to use it, this would not prevent the error but only the
error detection.



That's clear, but \PassOptions... at least gives you an opportunity to 
put some more options, and the result, or the lack of the result can be 
seen in the produced document.
So, first both LyX and user can \PassOptions..., LyX will or will not 
call some package at the end, in the latter case user will call it herself.



\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign} % set by LyX

\PassOptionsToPackage{something_other_than_utopia,greekuppercase=italicized}{mathdesign} 
% set by user



\usepackage{mathdesign} % called by either LyX or user

\begin{document}
$\Gamma$
\end{document}



Re: XeTeX - Load packages before fontspec

2011-10-09 Thread Guenter Milde
On 2011-10-08, PhilipPirrip wrote:
 On 10/07/2011 08:17 AM, Guenter Milde wrote:
   Custom LaTeX code before LyX-generated preamble:
+-+
| \usepackage[put]{mathdesign}|
| |
+-+

 May I object! ;)

Defeated. This was an *example* for a *custom* user written pe-preamble.

This specific example loads a package that is not auto-loaded by LyX, so
there is no danger of an option clash. It is put in the pre-preamble to
ensure it is loaded before the auto-loaded packages.

If the user wants to add options to a LyX-auto-loaded package, then this
could/should be done with \PassOptionsToPackage in the pre-preamble, but
without \usepackage command.

 Please always consider calling \usepackage in two parts, especially in
 LyX generated code: to allow for the possibility of adding more options
 to the packages called. (calling \usepackage with options twice isn't
 allowed)

Acutally, repeated \usepackages with a *different option set* is not
allowed. This is because the second \usepackage is ignored and hence the
different options are ignored too.

However, as the minimal example

\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign}
\usepackage{mathdesign}
\PassOptionsToPackage{greekuppercase=italicized}{mathdesign}
\usepackage{mathdesign}

\begin{document}
$\Gamma$
\end{document}

shows, \PassOptionsToPackage after \usepackage is silently ignored. 
I.e. if LyX were to use it, this would not prevent the error but only the
error detection.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-09 Thread PhilipPirrip

On 10/09/2011 05:45 PM, Guenter Milde wrote:


\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign}
\usepackage{mathdesign}
\PassOptionsToPackage{greekuppercase=italicized}{mathdesign}
\usepackage{mathdesign}

\begin{document}
$\Gamma$
\end{document}

shows, \PassOptionsToPackage after \usepackage is silently ignored.
I.e. if LyX were to use it, this would not prevent the error but only the
error detection.



That's clear, but \PassOptions... at least gives you an opportunity to 
put some more options, and the result, or the lack of the result can be 
seen in the produced document.
So, first both LyX and user can \PassOptions..., LyX will or will not 
call some package at the end, in the latter case user will call it herself.



\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign} % set by LyX

\PassOptionsToPackage{something_other_than_utopia,greekuppercase=italicized}{mathdesign} 
% set by user



\usepackage{mathdesign} % called by either LyX or user

\begin{document}
$\Gamma$
\end{document}



Re: XeTeX - Load packages before fontspec

2011-10-09 Thread Guenter Milde
On 2011-10-08, PhilipPirrip wrote:
> On 10/07/2011 08:17 AM, Guenter Milde wrote:
>>   Custom LaTeX code before LyX-generated preamble:
>>+-+
>>| \usepackage[put]{mathdesign}|
>>| |
>>+-+

> May I object! ;)

Defeated. This was an *example* for a *custom* user written pe-preamble.

This specific example loads a package that is not auto-loaded by LyX, so
there is no danger of an option clash. It is put in the pre-preamble to
ensure it is loaded before the auto-loaded packages.

If the user wants to add options to a LyX-auto-loaded package, then this
could/should be done with \PassOptionsToPackage in the pre-preamble, but
without \usepackage command.

> Please always consider calling \usepackage in two parts, especially in
> LyX generated code: to allow for the possibility of adding more options
> to the packages called. (calling \usepackage with options twice isn't
> allowed)

Acutally, repeated \usepackages with a *different option set* is not
allowed. This is because the second \usepackage is ignored and hence the
different options are ignored too.

However, as the minimal example

\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign}
\usepackage{mathdesign}
\PassOptionsToPackage{greekuppercase=italicized}{mathdesign}
\usepackage{mathdesign}

\begin{document}
$\Gamma$
\end{document}

shows, \PassOptionsToPackage after \usepackage is silently ignored. 
I.e. if LyX were to use it, this would not prevent the error but only the
error detection.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-09 Thread PhilipPirrip

On 10/09/2011 05:45 PM, Guenter Milde wrote:


\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign}
\usepackage{mathdesign}
\PassOptionsToPackage{greekuppercase=italicized}{mathdesign}
\usepackage{mathdesign}

\begin{document}
$\Gamma$
\end{document}

shows, \PassOptionsToPackage after \usepackage is silently ignored.
I.e. if LyX were to use it, this would not prevent the error but only the
error detection.



That's clear, but \PassOptions... at least gives you an opportunity to 
put some more options, and the result, or the lack of the result can be 
seen in the produced document.
So, first both LyX and user can \PassOptions..., LyX will or will not 
call some package at the end, in the latter case user will call it herself.



\documentclass{minimal}

\PassOptionsToPackage{utopia}{mathdesign} % set by LyX

\PassOptionsToPackage{something_other_than_utopia,greekuppercase=italicized}{mathdesign} 
% set by user



\usepackage{mathdesign} % called by either LyX or user

\begin{document}
$\Gamma$
\end{document}



Re: XeTeX - Load packages before fontspec

2011-10-08 Thread PhilipPirrip

On 10/07/2011 08:17 AM, Guenter Milde wrote:

  Custom LaTeX code before LyX-generated preamble:  
   +-+
   | \usepackage[put]{mathdesign}   |
   ||
   +-+



May I object! ;)
Please always consider calling \usepackage in two parts, especially in 
LyX generated code:


\PassOptionsToPackage{put}{mathdesign}
\usepackage{mathdesign}



to allow for the possibility of adding more options to the packages 
called. (calling \usepackage with options twice isn't allowed)




Custom LaTeX code before LyX-generated preamble:
  +-+
  | \PassOptionsToPackage{some_other_option}{mathdesign}|
  | |
  +-+

LyX-generated preamble:
 +-+
  | \PassOptionsToPackage{}{mathdesign} |
  | \usepackage{mathdesign} |
  +-+


Custom LaTeX code after LyX-generated preamble:
  +-+
  | \input{mypreamble}  |
  | |
  | |
  +-+









Re: XeTeX - Load packages before fontspec

2011-10-08 Thread PhilipPirrip

On 10/07/2011 08:17 AM, Guenter Milde wrote:

  Custom LaTeX code before LyX-generated preamble:  
   +-+
   | \usepackage[put]{mathdesign}   |
   ||
   +-+



May I object! ;)
Please always consider calling \usepackage in two parts, especially in 
LyX generated code:


\PassOptionsToPackage{put}{mathdesign}
\usepackage{mathdesign}



to allow for the possibility of adding more options to the packages 
called. (calling \usepackage with options twice isn't allowed)




Custom LaTeX code before LyX-generated preamble:
  +-+
  | \PassOptionsToPackage{some_other_option}{mathdesign}|
  | |
  +-+

LyX-generated preamble:
 +-+
  | \PassOptionsToPackage{}{mathdesign} |
  | \usepackage{mathdesign} |
  +-+


Custom LaTeX code after LyX-generated preamble:
  +-+
  | \input{mypreamble}  |
  | |
  | |
  +-+









Re: XeTeX - Load packages before fontspec

2011-10-08 Thread PhilipPirrip

On 10/07/2011 08:17 AM, Guenter Milde wrote:

  Custom LaTeX code before LyX-generated preamble:  
   +-+
   | \usepackage[put]{mathdesign}   |
   ||
   +-+



May I object! ;)
Please always consider calling \usepackage in two parts, especially in 
LyX generated code:


\PassOptionsToPackage{put}{mathdesign}
\usepackage{mathdesign}



to allow for the possibility of adding more options to the packages 
called. (calling \usepackage with options twice isn't allowed)




Custom LaTeX code before LyX-generated preamble:
  +-+
  | \PassOptionsToPackage{some_other_option}{mathdesign}|
  | |
  +-+

LyX-generated preamble:
 +-+
  | \PassOptionsToPackage{}{mathdesign} |
  | \usepackage{mathdesign} |
  +-+


Custom LaTeX code after LyX-generated preamble:
  +-+
  | \input{mypreamble}  |
  | |
  | |
  +-+









Re: XeTeX - Load packages before fontspec

2011-10-07 Thread Guenter Milde
On 2011-10-06, Spyros Stathopoulos wrote:
...

 In my opinion, however, it would be ideal if there was a way to
 configure when preamble statements are loaded (before or after lyx
 ones), but given the complexity that such a change would imply the
 current design is understandable.

You are right, there are several occasions, when inserting custom code
*before* the LyX-generated preamble would make power configuration easier.

However, in most cases this would be required in addition to the standard
(post-auto) LaTeX preamble, so a switch would not solve the problem.

Possible solutions include a second input field (maybe as fold-out or
with a draggable separator) inside the LaTeX Preamble tab:
  
  Custom LaTeX code before LyX-generated preamble:  
  +-+
  | \usepackage[put]{mathdesign}|
  | |
  +-+
  Custom LaTeX code after LyX-generated preamble:
  +-+
  | \input{mypreamble}  |
  | |
  | |
  +-+
  
However, there might, e.g. even be some code to put before \documentclass
and some code after \documentclass. For such a flexibility, the Docutils
latex writer uses an export-document template that can be replaced with a
custom one in a power-user command line option:

--template=file   Specify the template file. Default: default.tex.

with default.tex:

$head_prefix% generated by Docutils http://docutils.sourceforge.net/
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
$requirements
%%% Custom LaTeX preamble
$latex_preamble
%%% User specified packages and stylesheets
$stylesheet
%%% Fallback definitions for Docutils-specific commands
$fallbacks$pdfsetup
$titledata
%%% Body
\begin{document}
$body_pre_docinfo$docinfo$dedication$abstract$body
\end{document}


Günter



Re: XeTeX - Load packages before fontspec

2011-10-07 Thread Guenter Milde
On 2011-10-06, Spyros Stathopoulos wrote:
...

 In my opinion, however, it would be ideal if there was a way to
 configure when preamble statements are loaded (before or after lyx
 ones), but given the complexity that such a change would imply the
 current design is understandable.

You are right, there are several occasions, when inserting custom code
*before* the LyX-generated preamble would make power configuration easier.

However, in most cases this would be required in addition to the standard
(post-auto) LaTeX preamble, so a switch would not solve the problem.

Possible solutions include a second input field (maybe as fold-out or
with a draggable separator) inside the LaTeX Preamble tab:
  
  Custom LaTeX code before LyX-generated preamble:  
  +-+
  | \usepackage[put]{mathdesign}|
  | |
  +-+
  Custom LaTeX code after LyX-generated preamble:
  +-+
  | \input{mypreamble}  |
  | |
  | |
  +-+
  
However, there might, e.g. even be some code to put before \documentclass
and some code after \documentclass. For such a flexibility, the Docutils
latex writer uses an export-document template that can be replaced with a
custom one in a power-user command line option:

--template=file   Specify the template file. Default: default.tex.

with default.tex:

$head_prefix% generated by Docutils http://docutils.sourceforge.net/
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
$requirements
%%% Custom LaTeX preamble
$latex_preamble
%%% User specified packages and stylesheets
$stylesheet
%%% Fallback definitions for Docutils-specific commands
$fallbacks$pdfsetup
$titledata
%%% Body
\begin{document}
$body_pre_docinfo$docinfo$dedication$abstract$body
\end{document}


Günter



Re: XeTeX - Load packages before fontspec

2011-10-07 Thread Guenter Milde
On 2011-10-06, Spyros Stathopoulos wrote:
...

> In my opinion, however, it would be ideal if there was a way to
> configure when preamble statements are loaded (before or after lyx
> ones), but given the complexity that such a change would imply the
> current design is understandable.

You are right, there are several occasions, when inserting custom code
*before* the LyX-generated preamble would make "power configuration" easier.

However, in most cases this would be required in addition to the standard
(post-auto) LaTeX preamble, so a switch would not solve the problem.

Possible solutions include a second input field (maybe as fold-out or
with a draggable separator) inside the "LaTeX Preamble" tab:
  
  Custom LaTeX code before LyX-generated preamble:  
  +-+
  | \usepackage[put]{mathdesign}|
  | |
  +-+
  Custom LaTeX code after LyX-generated preamble:
  +-+
  | \input{mypreamble}  |
  | |
  | |
  +-+
  
However, there might, e.g. even be some code to put before \documentclass
and some code after \documentclass. For such a flexibility, the Docutils
latex writer uses an export-document template that can be replaced with a
custom one in a power-user command line option:

--template=   Specify the template file. Default: "default.tex".

with default.tex:

$head_prefix% generated by Docutils 
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
$requirements
%%% Custom LaTeX preamble
$latex_preamble
%%% User specified packages and stylesheets
$stylesheet
%%% Fallback definitions for Docutils-specific commands
$fallbacks$pdfsetup
$titledata
%%% Body
\begin{document}
$body_pre_docinfo$docinfo$dedication$abstract$body
\end{document}


Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Guenter Milde
On 2011-10-04, Spyros Stathopoulos wrote:

 I'm using the first option already since I need to pass options to the
 font definitions. Still the problem lies with fontspec not the font
 definition. 

The problem lies with mathdesign::

  %% 
  %% Encoding is automatically set to T1
  %% 
  
  \RequirePackage[T1]{fontenc}

The workaround is to re-set the TeX font encoding to EU1 (or U, if you use
LuaTeX). The following example:


\documentclass[english]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{english}

\usepackage[mdugm]{mathdesign}
%% Mathdesign sets font encoding to T1, reset with one of:
% \RequirePackage[EU1]{fontenc}
\renewcommand{\encodingdefault}{EU1}
\setmainfont[Mapping=tex-text]{Comic Sans MS}

\begin{document}
Was ist das?
\[
2^{2}=4
\]
\end{document}


results in mathdesign math and comic text fonts.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Guenter Milde
On 2011-10-04, Spyros Stathopoulos wrote:
 I've been trying to create a custom module but unfortunately is seems
 that fontspec is not handled by a module at all, instead it is placed
 into the preamble automatically when XeTeX mode is triggered. 

I believe the idea was to load mathdesign in a module. However, I did not
test whether it is possible to load it before fontenc to reset the
TeX font encoding to EU1 or U.

 In the end the only thing that did the job was modifying a local copy
 of the .cls, which is not too bad actually. However, given the
 peculiarity of fontspec with a lot of font-affecting packages there
 should be a way to override or customize this kind of behavior (along
 with passing options to \setXfont) without resorting to modifying
 classes and/or packages. Other than that I'm quite happy with the way
 LyX handles XeTeX.

Actually, the use non-TeX fonts option is a use fontspec option,
combining this with 8-bit font packages is always tricky. Supporting these
combinations in the GUI would make things too complicated.

I could rather imagine to add polyglossia to the selection in 
DocumentSettingsLanguagesLanguage package. This way, it would be possible
to have XeTeX + polyglossia also without selecting fontspec per GUI.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Spyros Stathopoulos
Thank you Günter, the encoding trick indeed solved the problem.
In my opinion, however, it would be ideal if there was a way to configure when
preamble statements are loaded (before or after lyx ones), but given the
complexity that such a change would imply the current design is understandable.

Again, thanks for the tip! :)
Spyros

On 10/06/2011 11:12 AM, Guenter Milde wrote:
 On 2011-10-04, Spyros Stathopoulos wrote:
 
 I'm using the first option already since I need to pass options to the
 font definitions. Still the problem lies with fontspec not the font
 definition. 
 
 The problem lies with mathdesign::
 
   %% 
   %% Encoding is automatically set to T1
   %% 
   
   \RequirePackage[T1]{fontenc}
 
 The workaround is to re-set the TeX font encoding to EU1 (or U, if you use
 LuaTeX). The following example:
 
 
 \documentclass[english]{article}
 \usepackage{fontspec}
 \usepackage{xunicode}
 \usepackage{polyglossia}
 \setdefaultlanguage{english}
 
 \usepackage[mdugm]{mathdesign}
 %% Mathdesign sets font encoding to T1, reset with one of:
 % \RequirePackage[EU1]{fontenc}
 \renewcommand{\encodingdefault}{EU1}
 \setmainfont[Mapping=tex-text]{Comic Sans MS}
 
 \begin{document}
 Was ist das?
 \[
 2^{2}=4
 \]
 \end{document}
 
 
 results in mathdesign math and comic text fonts.
 
 Günter
 



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Guenter Milde
On 2011-10-04, Spyros Stathopoulos wrote:

 I'm using the first option already since I need to pass options to the
 font definitions. Still the problem lies with fontspec not the font
 definition. 

The problem lies with mathdesign::

  %% 
  %% Encoding is automatically set to T1
  %% 
  
  \RequirePackage[T1]{fontenc}

The workaround is to re-set the TeX font encoding to EU1 (or U, if you use
LuaTeX). The following example:


\documentclass[english]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{english}

\usepackage[mdugm]{mathdesign}
%% Mathdesign sets font encoding to T1, reset with one of:
% \RequirePackage[EU1]{fontenc}
\renewcommand{\encodingdefault}{EU1}
\setmainfont[Mapping=tex-text]{Comic Sans MS}

\begin{document}
Was ist das?
\[
2^{2}=4
\]
\end{document}


results in mathdesign math and comic text fonts.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Guenter Milde
On 2011-10-04, Spyros Stathopoulos wrote:
 I've been trying to create a custom module but unfortunately is seems
 that fontspec is not handled by a module at all, instead it is placed
 into the preamble automatically when XeTeX mode is triggered. 

I believe the idea was to load mathdesign in a module. However, I did not
test whether it is possible to load it before fontenc to reset the
TeX font encoding to EU1 or U.

 In the end the only thing that did the job was modifying a local copy
 of the .cls, which is not too bad actually. However, given the
 peculiarity of fontspec with a lot of font-affecting packages there
 should be a way to override or customize this kind of behavior (along
 with passing options to \setXfont) without resorting to modifying
 classes and/or packages. Other than that I'm quite happy with the way
 LyX handles XeTeX.

Actually, the use non-TeX fonts option is a use fontspec option,
combining this with 8-bit font packages is always tricky. Supporting these
combinations in the GUI would make things too complicated.

I could rather imagine to add polyglossia to the selection in 
DocumentSettingsLanguagesLanguage package. This way, it would be possible
to have XeTeX + polyglossia also without selecting fontspec per GUI.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Spyros Stathopoulos
Thank you Günter, the encoding trick indeed solved the problem.
In my opinion, however, it would be ideal if there was a way to configure when
preamble statements are loaded (before or after lyx ones), but given the
complexity that such a change would imply the current design is understandable.

Again, thanks for the tip! :)
Spyros

On 10/06/2011 11:12 AM, Guenter Milde wrote:
 On 2011-10-04, Spyros Stathopoulos wrote:
 
 I'm using the first option already since I need to pass options to the
 font definitions. Still the problem lies with fontspec not the font
 definition. 
 
 The problem lies with mathdesign::
 
   %% 
   %% Encoding is automatically set to T1
   %% 
   
   \RequirePackage[T1]{fontenc}
 
 The workaround is to re-set the TeX font encoding to EU1 (or U, if you use
 LuaTeX). The following example:
 
 
 \documentclass[english]{article}
 \usepackage{fontspec}
 \usepackage{xunicode}
 \usepackage{polyglossia}
 \setdefaultlanguage{english}
 
 \usepackage[mdugm]{mathdesign}
 %% Mathdesign sets font encoding to T1, reset with one of:
 % \RequirePackage[EU1]{fontenc}
 \renewcommand{\encodingdefault}{EU1}
 \setmainfont[Mapping=tex-text]{Comic Sans MS}
 
 \begin{document}
 Was ist das?
 \[
 2^{2}=4
 \]
 \end{document}
 
 
 results in mathdesign math and comic text fonts.
 
 Günter
 



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Guenter Milde
On 2011-10-04, Spyros Stathopoulos wrote:

> I'm using the first option already since I need to pass options to the
> font definitions. Still the problem lies with fontspec not the font
> definition. 

The problem lies with mathdesign::

  %% 
  %% Encoding is automatically set to T1
  %% 
  
  \RequirePackage[T1]{fontenc}

The workaround is to re-set the TeX font encoding to EU1 (or U, if you use
LuaTeX). The following example:


\documentclass[english]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{english}

\usepackage[mdugm]{mathdesign}
%% Mathdesign sets font encoding to T1, reset with one of:
% \RequirePackage[EU1]{fontenc}
\renewcommand{\encodingdefault}{EU1}
\setmainfont[Mapping=tex-text]{Comic Sans MS}

\begin{document}
Was ist das?
\[
2^{2}=4
\]
\end{document}


results in mathdesign math and comic text fonts.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Guenter Milde
On 2011-10-04, Spyros Stathopoulos wrote:
> I've been trying to create a custom module but unfortunately is seems
> that fontspec is not handled by a module at all, instead it is placed
> into the preamble automatically when XeTeX mode is triggered. 

I believe the idea was to load mathdesign in a module. However, I did not
test whether it is possible to load it before fontenc to reset the
TeX font encoding to EU1 or U.

> In the end the only thing that did the job was modifying a local copy
> of the .cls, which is not too bad actually. However, given the
> peculiarity of fontspec with a lot of font-affecting packages there
> should be a way to override or customize this kind of behavior (along
> with passing options to \setXfont) without resorting to modifying
> classes and/or packages. Other than that I'm quite happy with the way
> LyX handles XeTeX.

Actually, the "use non-TeX fonts" option is a "use fontspec" option,
combining this with 8-bit font packages is always tricky. Supporting these
combinations in the GUI would make things too complicated.

I could rather imagine to add "polyglossia" to the selection in 
Document>Settings>Languages>Language package. This way, it would be possible
to have XeTeX + polyglossia also without selecting fontspec per GUI.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-06 Thread Spyros Stathopoulos
Thank you Günter, the encoding trick indeed solved the problem.
In my opinion, however, it would be ideal if there was a way to configure when
preamble statements are loaded (before or after lyx ones), but given the
complexity that such a change would imply the current design is understandable.

Again, thanks for the tip! :)
Spyros

On 10/06/2011 11:12 AM, Guenter Milde wrote:
> On 2011-10-04, Spyros Stathopoulos wrote:
> 
>> I'm using the first option already since I need to pass options to the
>> font definitions. Still the problem lies with fontspec not the font
>> definition. 
> 
> The problem lies with mathdesign::
> 
>   %% 
>   %% Encoding is automatically set to T1
>   %% 
>   
>   \RequirePackage[T1]{fontenc}
> 
> The workaround is to re-set the TeX font encoding to EU1 (or U, if you use
> LuaTeX). The following example:
> 
> 
> \documentclass[english]{article}
> \usepackage{fontspec}
> \usepackage{xunicode}
> \usepackage{polyglossia}
> \setdefaultlanguage{english}
> 
> \usepackage[mdugm]{mathdesign}
> %% Mathdesign sets font encoding to T1, reset with one of:
> % \RequirePackage[EU1]{fontenc}
> \renewcommand{\encodingdefault}{EU1}
> \setmainfont[Mapping=tex-text]{Comic Sans MS}
> 
> \begin{document}
> Was ist das?
> \[
> 2^{2}=4
> \]
> \end{document}
> 
> 
> results in mathdesign math and comic text fonts.
> 
> Günter
> 



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Guenter Milde
On 2011-10-01, Spyros Stathopoulos wrote:
 Hello everyone! I've been using TeX for quite a long time now but I'm new to
 LyX. I've managed to create some fairly long documents with it and XeTeX and
 I'm quite happy, however there is one little thing that troubles me. A lot of
 regular LaTeX packages that affect fonts need to be loaded before fontspec in
 order to work properly. One such package, for example, is mathdesign. In order
 to apply a mathdesign font to the math text using XeTeX/fontspec, mathdesign
 must be loaded before fontspec, like this

 \usepackage[mdugm]{mathdesign}
 \usepackage{fontspec}
 ...

 However, LyX automatically inserts fontspec at the very top of the preamble
 (actually, after amsmath but you get the point). Therefore if I put
 \usepackage[...]{mathdesign} in the preamble settings it always comes after
 fontspec and renders the fontspec font definitions useless. Of course the same
 happends if I \usepackage{fontspec} again in the preamble (since it's already
 loaded).

 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.

Two options:

* Try with the font definitions in the user preamble, e.g.

\setmainfont[Mapping=tex-text]{Asana Math}
...
  
  (You can find the commands with ViewSource ticking the Complete source
  box. Set the GUI font selection to Default afterwards.)
  
* - Leave use non-Tex fonts unchecked.
  - Select LanguageEncoding  Unicode (utf-8) (XeTeX)
  - Do the complete fontspec loading and configuration in the user preamble.
  - View/Export with XeTeX.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Spyros Stathopoulos
I'm using the first option already since I need to pass options to the font
definitions. Still the problem lies with fontspec not the font definition. I've
also thought about the second method but that way I lose the nice integration
with polyglossia since LyX will be using babel (instead of polyglossia) for
multilingual text.

Spyros

On 10/04/2011 10:54 AM, Guenter Milde wrote:
 On 2011-10-01, Spyros Stathopoulos wrote:
 Hello everyone! I've been using TeX for quite a long time now but I'm new to
 LyX. I've managed to create some fairly long documents with it and XeTeX and
 I'm quite happy, however there is one little thing that troubles me. A lot of
 regular LaTeX packages that affect fonts need to be loaded before fontspec in
 order to work properly. One such package, for example, is mathdesign. In 
 order
 to apply a mathdesign font to the math text using XeTeX/fontspec, mathdesign
 must be loaded before fontspec, like this
 
 \usepackage[mdugm]{mathdesign}
 \usepackage{fontspec}
 ...
 
 However, LyX automatically inserts fontspec at the very top of the preamble
 (actually, after amsmath but you get the point). Therefore if I put
 \usepackage[...]{mathdesign} in the preamble settings it always comes after
 fontspec and renders the fontspec font definitions useless. Of course the 
 same
 happends if I \usepackage{fontspec} again in the preamble (since it's already
 loaded).
 
 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.
 
 Two options:
 
 * Try with the font definitions in the user preamble, e.g.
 
 \setmainfont[Mapping=tex-text]{Asana Math}
 ...
   
   (You can find the commands with ViewSource ticking the Complete source
   box. Set the GUI font selection to Default afterwards.)
   
 * - Leave use non-Tex fonts unchecked.
   - Select LanguageEncoding  Unicode (utf-8) (XeTeX)
   - Do the complete fontspec loading and configuration in the user preamble.
   - View/Export with XeTeX.
 
 Günter
 



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Julien Rioux

On 04/10/2011 12:02 PM, Spyros Stathopoulos wrote:

Is there any (hackish?) way to tell LyX to load mathdesign (or any other
package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.


You could try your luck with the approach described in this thread:
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg170949.html

Alternatively you can modify your .cls file to load mathdesign for you.

Cheers,
Julien



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Spyros Stathopoulos
I've been trying to create a custom module but unfortunately is seems that
fontspec is not handled by a module at all, instead it is placed into the
preamble automatically when XeTeX mode is triggered. In the end the only thing
that did the job was modifying a local copy of the .cls, which is not too bad
actually. However, given the peculiarity of fontspec with a lot of
font-affecting packages there should be a way to override or customize this
kind of behavior (along with passing options to \setXfont) without resorting to
modifying classes and/or packages. Other than that I'm quite happy with the way
LyX handles XeTeX.

Thanks for the tips!
Spyros

On 10/04/2011 06:49 PM, Julien Rioux wrote:
 On 04/10/2011 12:02 PM, Spyros Stathopoulos wrote:
 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.
 
 You could try your luck with the approach described in this thread:
 http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg170949.html
 
 Alternatively you can modify your .cls file to load mathdesign for you.
 
 Cheers,
 Julien
 



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Guenter Milde
On 2011-10-01, Spyros Stathopoulos wrote:
 Hello everyone! I've been using TeX for quite a long time now but I'm new to
 LyX. I've managed to create some fairly long documents with it and XeTeX and
 I'm quite happy, however there is one little thing that troubles me. A lot of
 regular LaTeX packages that affect fonts need to be loaded before fontspec in
 order to work properly. One such package, for example, is mathdesign. In order
 to apply a mathdesign font to the math text using XeTeX/fontspec, mathdesign
 must be loaded before fontspec, like this

 \usepackage[mdugm]{mathdesign}
 \usepackage{fontspec}
 ...

 However, LyX automatically inserts fontspec at the very top of the preamble
 (actually, after amsmath but you get the point). Therefore if I put
 \usepackage[...]{mathdesign} in the preamble settings it always comes after
 fontspec and renders the fontspec font definitions useless. Of course the same
 happends if I \usepackage{fontspec} again in the preamble (since it's already
 loaded).

 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.

Two options:

* Try with the font definitions in the user preamble, e.g.

\setmainfont[Mapping=tex-text]{Asana Math}
...
  
  (You can find the commands with ViewSource ticking the Complete source
  box. Set the GUI font selection to Default afterwards.)
  
* - Leave use non-Tex fonts unchecked.
  - Select LanguageEncoding  Unicode (utf-8) (XeTeX)
  - Do the complete fontspec loading and configuration in the user preamble.
  - View/Export with XeTeX.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Spyros Stathopoulos
I'm using the first option already since I need to pass options to the font
definitions. Still the problem lies with fontspec not the font definition. I've
also thought about the second method but that way I lose the nice integration
with polyglossia since LyX will be using babel (instead of polyglossia) for
multilingual text.

Spyros

On 10/04/2011 10:54 AM, Guenter Milde wrote:
 On 2011-10-01, Spyros Stathopoulos wrote:
 Hello everyone! I've been using TeX for quite a long time now but I'm new to
 LyX. I've managed to create some fairly long documents with it and XeTeX and
 I'm quite happy, however there is one little thing that troubles me. A lot of
 regular LaTeX packages that affect fonts need to be loaded before fontspec in
 order to work properly. One such package, for example, is mathdesign. In 
 order
 to apply a mathdesign font to the math text using XeTeX/fontspec, mathdesign
 must be loaded before fontspec, like this
 
 \usepackage[mdugm]{mathdesign}
 \usepackage{fontspec}
 ...
 
 However, LyX automatically inserts fontspec at the very top of the preamble
 (actually, after amsmath but you get the point). Therefore if I put
 \usepackage[...]{mathdesign} in the preamble settings it always comes after
 fontspec and renders the fontspec font definitions useless. Of course the 
 same
 happends if I \usepackage{fontspec} again in the preamble (since it's already
 loaded).
 
 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.
 
 Two options:
 
 * Try with the font definitions in the user preamble, e.g.
 
 \setmainfont[Mapping=tex-text]{Asana Math}
 ...
   
   (You can find the commands with ViewSource ticking the Complete source
   box. Set the GUI font selection to Default afterwards.)
   
 * - Leave use non-Tex fonts unchecked.
   - Select LanguageEncoding  Unicode (utf-8) (XeTeX)
   - Do the complete fontspec loading and configuration in the user preamble.
   - View/Export with XeTeX.
 
 Günter
 



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Julien Rioux

On 04/10/2011 12:02 PM, Spyros Stathopoulos wrote:

Is there any (hackish?) way to tell LyX to load mathdesign (or any other
package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.


You could try your luck with the approach described in this thread:
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg170949.html

Alternatively you can modify your .cls file to load mathdesign for you.

Cheers,
Julien



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Spyros Stathopoulos
I've been trying to create a custom module but unfortunately is seems that
fontspec is not handled by a module at all, instead it is placed into the
preamble automatically when XeTeX mode is triggered. In the end the only thing
that did the job was modifying a local copy of the .cls, which is not too bad
actually. However, given the peculiarity of fontspec with a lot of
font-affecting packages there should be a way to override or customize this
kind of behavior (along with passing options to \setXfont) without resorting to
modifying classes and/or packages. Other than that I'm quite happy with the way
LyX handles XeTeX.

Thanks for the tips!
Spyros

On 10/04/2011 06:49 PM, Julien Rioux wrote:
 On 04/10/2011 12:02 PM, Spyros Stathopoulos wrote:
 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.
 
 You could try your luck with the approach described in this thread:
 http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg170949.html
 
 Alternatively you can modify your .cls file to load mathdesign for you.
 
 Cheers,
 Julien
 



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Guenter Milde
On 2011-10-01, Spyros Stathopoulos wrote:
> Hello everyone! I've been using TeX for quite a long time now but I'm new to
> LyX. I've managed to create some fairly long documents with it and XeTeX and
> I'm quite happy, however there is one little thing that troubles me. A lot of
> regular LaTeX packages that affect fonts need to be loaded before fontspec in
> order to work properly. One such package, for example, is mathdesign. In order
> to apply a mathdesign font to the math text using XeTeX/fontspec, mathdesign
> must be loaded before fontspec, like this

> \usepackage[mdugm]{mathdesign}
> \usepackage{fontspec}
> ...

> However, LyX automatically inserts fontspec at the very top of the preamble
> (actually, after amsmath but you get the point). Therefore if I put
> \usepackage[...]{mathdesign} in the preamble settings it always comes after
> fontspec and renders the fontspec font definitions useless. Of course the same
> happends if I \usepackage{fontspec} again in the preamble (since it's already
> loaded).

> Is there any (hackish?) way to tell LyX to load mathdesign (or any other
> package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.

Two options:

* Try with the font definitions in the user preamble, e.g.

\setmainfont[Mapping=tex-text]{Asana Math}
...
  
  (You can find the commands with View>Source ticking the "Complete source"
  box. Set the GUI font selection to "Default" afterwards.)
  
* - Leave "use non-Tex fonts" unchecked.
  - Select Language>Encoding  Unicode (utf-8) (XeTeX)
  - Do the complete fontspec loading and configuration in the user preamble.
  - View/Export with XeTeX.

Günter



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Spyros Stathopoulos
I'm using the first option already since I need to pass options to the font
definitions. Still the problem lies with fontspec not the font definition. I've
also thought about the second method but that way I lose the nice integration
with polyglossia since LyX will be using babel (instead of polyglossia) for
multilingual text.

Spyros

On 10/04/2011 10:54 AM, Guenter Milde wrote:
> On 2011-10-01, Spyros Stathopoulos wrote:
>> Hello everyone! I've been using TeX for quite a long time now but I'm new to
>> LyX. I've managed to create some fairly long documents with it and XeTeX and
>> I'm quite happy, however there is one little thing that troubles me. A lot of
>> regular LaTeX packages that affect fonts need to be loaded before fontspec in
>> order to work properly. One such package, for example, is mathdesign. In 
>> order
>> to apply a mathdesign font to the math text using XeTeX/fontspec, mathdesign
>> must be loaded before fontspec, like this
> 
>> \usepackage[mdugm]{mathdesign}
>> \usepackage{fontspec}
>> ...
> 
>> However, LyX automatically inserts fontspec at the very top of the preamble
>> (actually, after amsmath but you get the point). Therefore if I put
>> \usepackage[...]{mathdesign} in the preamble settings it always comes after
>> fontspec and renders the fontspec font definitions useless. Of course the 
>> same
>> happends if I \usepackage{fontspec} again in the preamble (since it's already
>> loaded).
> 
>> Is there any (hackish?) way to tell LyX to load mathdesign (or any other
>> package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.
> 
> Two options:
> 
> * Try with the font definitions in the user preamble, e.g.
> 
> \setmainfont[Mapping=tex-text]{Asana Math}
> ...
>   
>   (You can find the commands with View>Source ticking the "Complete source"
>   box. Set the GUI font selection to "Default" afterwards.)
>   
> * - Leave "use non-Tex fonts" unchecked.
>   - Select Language>Encoding  Unicode (utf-8) (XeTeX)
>   - Do the complete fontspec loading and configuration in the user preamble.
>   - View/Export with XeTeX.
> 
> Günter
> 



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Julien Rioux

On 04/10/2011 12:02 PM, Spyros Stathopoulos wrote:

Is there any (hackish?) way to tell LyX to load mathdesign (or any other
package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.


You could try your luck with the approach described in this thread:
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg170949.html

Alternatively you can modify your .cls file to load mathdesign for you.

Cheers,
Julien



Re: XeTeX - Load packages before fontspec

2011-10-04 Thread Spyros Stathopoulos
I've been trying to create a custom module but unfortunately is seems that
fontspec is not handled by a module at all, instead it is placed into the
preamble automatically when XeTeX mode is triggered. In the end the only thing
that did the job was modifying a local copy of the .cls, which is not too bad
actually. However, given the peculiarity of fontspec with a lot of
font-affecting packages there should be a way to override or customize this
kind of behavior (along with passing options to \setXfont) without resorting to
modifying classes and/or packages. Other than that I'm quite happy with the way
LyX handles XeTeX.

Thanks for the tips!
Spyros

On 10/04/2011 06:49 PM, Julien Rioux wrote:
> On 04/10/2011 12:02 PM, Spyros Stathopoulos wrote:
 Is there any (hackish?) way to tell LyX to load mathdesign (or any other
 package) before fontspec? I'm using LyX 2.0.1 + TeXLive 2010 on ArchLinux.
> 
> You could try your luck with the approach described in this thread:
> http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg170949.html
> 
> Alternatively you can modify your .cls file to load mathdesign for you.
> 
> Cheers,
> Julien
>