7

I have a document that I was writing with UTF-8 chars using TexStudio, MikTex (x64) and pdflatex. All updated and running on Window 7 SP1 x64.

Then I decided to start using biblatex citations and now I have an incompatibility problem.

The error is

Package biblatex Error: Incompatible package 'ucs'. \begin{document}

And here is the code

\documentclass[]{article}
\usepackage[mathletters]{ucs} % this package seems to conflict
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc} % the x seems to be a problem
\usepackage[backend=bibtex]{biblatex}
\addbibresource{Library.bib}

\title{MyTitle}
\author{Me}

\begin{document}

    \maketitle

    \section{MySection}

    \paragraph{MyParagraph}
    Accènt
    λ lamba
    \cite{some_cit}

    \printbibliography

\end{document}

This is a small example. In my full document I have lots of Greek letters, and some of them are in titles. Putting them all into math formulas would be a problem. What should I do? to make the 2 live together? Should I use another package for citations?

  • 2
    The documentation of biblatex is clear: it is incompatible with utf8x. Just do \usepackage[utf8]{inputenc}. Can you make a real example of what you're using the mathletters option to ucs for? – egreg Nov 20 '14 at 23:02
  • I read somewhere that the utf8x incompatibility was fixed. Maybe I remember wrong, but just writing "utf8" instead of "utf8x" produces the same error. I also have to give up the mathletters, but then I can't paste math symbols anymore. It's clearer to see ∞ than to see $∞$, no? – Agostino Nov 20 '14 at 23:05
  • No, it isn't. Math symbols should go in math formulas. – egreg Nov 20 '14 at 23:08
  • 1
    I've never had problems with math formulas in titles. What mathletters does is defining some symbols with \ensuremath around them. – egreg Nov 20 '14 at 23:21
  • 1
    maths formulas should not create problems in titles (the definitions need to be robust but that applies equally to the text versions) – David Carlisle Nov 20 '14 at 23:22
7

You can abuse the infrastructure of ucs; here's a set of tricks that read the files you need in the ucs distribution, but under utf8 which is compatible with biblatex.

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\input{binhex}
\makeatletter
\def\uc@dclc#1#2#3{%
  \ifnum\pdfstrcmp{#2}{mathletters}=\z@
    \begingroup\edef\x{\endgroup
      \noexpand\DeclareUnicodeCharacter{\hex{#1}}}\x{#3}%
  \fi
}
\input{uni-3.def}
\def\uc@dclc#1#2#3{%
  \ifnum\pdfstrcmp{#2}{default}=\z@
    \begingroup\edef\x{\endgroup
      \noexpand\DeclareUnicodeCharacter{\hex{#1}}}\x{#3}%
  \fi
}
\input{uni-34.def}
\makeatother


\begin{document}
\title{MyTitle}
\author{Me}

\maketitle

\section{MySection about ∞}

Accènt λ lambda ∞ 

$λ$ lambda $∞$ 


\end{document}

enter image description here

A different strategy is using unicode-math-table.tex:

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\makeatletter
\newcommand\UnicodeMathSymbol[4]{%
  \ifnum#1>"9F
    \expandafter\DeclareUnicodeCharacter\expandafter{\@gobble#1}{\ensuremath{#2}}%
  \fi
}
\input{unicode-math-table}
\@for\next:={% you're probably using text Greek letters
  alpha,beta,gamma,delta,epsilon,zeta,eta,theta,%
  iota,kappa,lambda,mu,nu,xi,pi,rho,sigma,tau,%
  upsilon,phi,chi,psi,omega,Gamma,Delta,Theta,%
  Lambda,Xi,Pi,Sigma,Upsilon,Phi,Psi,Omega}\do{%
    \expandafter\let\csname up\next\expandafter\endcsname\csname\next\endcsname
}

\makeatother

\begin{document}
\title{MyTitle}
\author{Me}

\maketitle

\section{MySection about ∞}

Accènt
λ lambda ∞ 

$λ$ lambda $∞$ 


\end{document}

The entries in unicode-math-table are of the form

\UnicodeMathSymbol{"0221E}{\infty}{\mathord}{infinity}

so we remap this to

\DeclareUnicodeCharacter{0221E}{\ensuremath{\infty}}

(I used \ensuremath because you want it, but I'd personally avoid it). For the Greek letters, \upalpha and so on are used, so I remap also those commands to the usual ones.

  • Wow, this seems to work well. Could you add some comments to your code, or give some more details about how this works? Thanks. – Agostino Nov 20 '14 at 23:48
  • Thanks. I'm actually not sure I really need the \ensuremath. You are right that I would prefer the Greek letters to be text (except when they appear in formulas). Does the second solution account for both the small and upper case (e.g. δ Δ)? Which solution would you consider "cleaner"? – Agostino Nov 21 '14 at 11:36
  • @Agostino None of them is “clean”. – egreg Nov 21 '14 at 11:37
  • 1
    @Agostino $a_{λ}$ shouldn't make problem. – egreg Nov 21 '14 at 11:47
  • 1
    @Agostino Why? Use TeX's math features! – egreg Nov 21 '14 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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