Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Basically, I have encountered the same error as answered here and the workaround suggested by Andrey Vihrov reenables me to compile the document. The problem now is, that any shorthand defined by the ngerman-package (most notably the non-breaking hypen "~) has now been disabled, and I see combinations of american style closing quotes followed by a non-break space where a non-breaking hyphen should be.

Is there any way possible of keeping the shorthand definition, or redefining it to something else (something like \nbhy pops up to mind)?

I am using XeLaTeX as supplied by TeXLive.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This seems to work. Basically we are overriding the meaning of the active " in math mode.

\documentclass{article}

\usepackage{mathspec}
\setallmainfonts[Ligatures=TeX,Numbers={Lining,Proportional}]{Linux Libertine O}

\usepackage{polyglossia}
\setmainlanguage[babelshorthands,spelling=new]{german}

\makeatletter
\begingroup\lccode`~=`"
\lowercase{\endgroup
  \everymath{\let~\eu@active@quote}
  \everydisplay{\let~\eu@active@quote}
}
\makeatother

\begin{document}
a"~b

\begin{equation}
f(x)=\sigma
\end{equation}
\end{document}

I wouldn't use the ngerman package, which is obsolete even for LaTeX.

You can also use babel, if you don't have an up-to-date version of Polyglossia.

\documentclass{article}

\usepackage{mathspec}
\setallmainfonts[Ligatures=TeX,Numbers={Lining,Proportional}]{Linux Libertine O}

\usepackage[ngerman]{babel}

\makeatletter
\begingroup\lccode`~=`"
\lowercase{\endgroup
  \everymath{\let~\eu@active@quote}
  \everydisplay{\let~\eu@active@quote}
}
\makeatother

\begin{document}
a"~b

\begin{equation}
f(x)=\sigma
\end{equation}
\end{document}
share|improve this answer
    
Something's not working … Changed the ngerman to your polyglossia definition and added the \makeatletter stuff, reran xelatex and I still see " i.e. double quotes followed by a space. If I change it to babelshorthands=false, same thing. If I now change it to babelshorthands=true, I get an error, telling me that a missing { was inserted. Interestingly enough, it was inserted into the line \begin{document}, because apparantly XeLaTeX couldn't find it there, and now I am confused. Edit: Sorry, I hit return, thinking it would make a new line, but it didn't. –  Jan Jul 6 '12 at 22:31
    
@Jan Please, be more specific. –  egreg Jul 6 '12 at 22:33
    
see edited version of above comment. It's weird that one cannot use simple return to create new lines … –  Jan Jul 6 '12 at 22:41
    
@Jan No, in comments you have to do Shift+Return. What TeX distribution are you using? I suspect an outdated one. By the way, welcome to TeX.SX! You may try with ngerman in place of the Polyglossia related lines, but you'd better upgrade. –  egreg Jul 6 '12 at 22:48
    
TeXLive as it was supplied to go with Lubuntu … This is XeTeX, Version 3.1415926-2.2-0.9995.2 (TeX Live 2009/Debian) –  Jan Jul 6 '12 at 22:50
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.