0

How would you implement the "catcode" solution here for superscripts? Thanks

EDIT

The code below reproduces the error (complied using XeLaTeX). Works if the following two lines are commented out:

\catcode`^=\active
\newcommand^[1]{\ensuremath{\sp{\scriptscriptstyle #1}}}

Full code:

\documentclass[11pt,english,no-math]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Calibri}
\usepackage{geometry}
\geometry{verbose,tmargin=0.8in,bmargin=0.8in,lmargin=0.8in,rmargin=0.8in}



\catcode`_=\active
\newcommand_[1]{\ensuremath{\sb{\scriptscriptstyle #1}}}

\catcode`^=\active
\newcommand^[1]{\ensuremath{\sp{\scriptscriptstyle #1}}}


\usepackage[dvipsnames]{xcolor}

\usepackage{titlesec}
\titleformat*{\section}{\LARGE\bfseries\color{RoyalBlue}}
\titleformat*{\subsection}{\Large\bfseries\color{RoyalBlue}}


\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\begin{document}


\section{Set up}

\begin{align*}
\int_{n-1}^{n}c_{n}dt & =x\left(i,n\right)\\
\implies c_{n} & =x\left(i,n\right)
\end{align*}

\end{document}
  • 1
    just copy the code replacing _ by ^ and \sb by \sp – David Carlisle Jan 30 '18 at 1:49
  • Thanks, David. I did that, but it didn't work for some reason. \catcode`^=\active \newcommand^[1]{\ensuremath{\sp{\scriptscriptstyle #1}}} – gsab Jan 30 '18 at 1:53
  • 2
    if you want help with an error message the question is always clearer if it includes a complete test document that produces the error and the exact error message you got. "did not work" is hard to debug. – David Carlisle Jan 30 '18 at 1:57
  • 1
    What's the error message? – cfr Jan 30 '18 at 2:19
  • ! Missing number, treated as zero. <to be read again> \protect l.1455 \XC@catcodes – gsab Jan 30 '18 at 2:24
2

The error comes because you're changing category codes before TeX processes certain files that don't expect those category codes:

\catcode`^=\active
\newcommand^[1]{\ensuremath{\sp{\scriptscriptstyle #1}}}

\usepackage[dvipsnames]{xcolor}

This means that xcolor.sty is processed with the new catcode for ^ (not something it is prepared for), which can lead to undesirable results. Similar problems with having this redefinition before \usepackage{xunicode}.

Move these \catcode-changing lines to after all external files have been loaded. Say, just before or after \begin{document}. Then the error goes away.

| improve this answer | |

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.