3

The operation ^ (i.e. e^x) is not working properly. When I write ^ Texmaker sometimes stops working.

I am using a MacBook if this has any influence.

EDIT:

enter image description here

So now it froze. Can't do anything. Can't delete, can't mark the text and can't print the PDF. I can 'Save as' to continue, but AFAIK that's it.

This is the document where it freezes sometimes when I use '^'. This is the code:

\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{refstyle}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage{mathrsfs}
\fancyhf{}
\fancyhead [L]{}
\fancyhead [R] {}
\rfoot{page \thepage \hspace{1pt} of
\pageref{LastPage}}
\renewcommand\headrulewidth{1pt}
\pagestyle{fancy}

\begin{document}

\[
^
\]

\end{document}
  • 2
    I have to ask: Are you using $e^x$? – Werner Apr 18 '17 at 19:31
  • If it isn't what Werner suggested, post explicit code an cite the explicit error message – daleif Apr 18 '17 at 19:33
  • 1
    I think there is a misunderstanding here about what is "Latex". I believe @NikolaiBonnerup is saying that his editor sometimes freezes when he types the ^ character. – TonioElGringo Apr 19 '17 at 12:12
  • 1
    There is some text-editing wonkiness in Sierra (see, for example, discussions.apple.com/thread/7778906 ). What program are you using? (You don't seem to mention.) Can you trigger the problem reliably by typing enough ^s? If so, how many? – LSpice Apr 19 '17 at 15:06
  • 2
    I am using texmaker, and yeah it's the editor thats freezing. And yes I can trigger it kind of reliably. The amount of '^' I have to use is not consistent though. – Nikolai Bonnerup Apr 19 '17 at 15:54
13

^ is a math mode command for a superscript and ^^ is a general command (like the control key) to shift the character code of the following character by 64.

so in text mode with one ^

\documentclass{article}

\begin{document}

^

\end{document}

you get the error

! Missing $ inserted.
<inserted text> 
                $
l.5 ^

with two ^^

you get no error, and it typesets an M as end of line is control-M so shifting that by 64 gives M

with three ^^^

you get the error

! Text line contains an invalid character.
l.5 ^^^

as control-^ (character hex 1E, decimal 30) isn't set up as an input character.

Adding more ^ will just give multiple occurrences of these errors unless you stop at the first one.


As the example in the question has been changed I will repeat the above but with math mode.

In display math with one ^

\documentclass{article}

\begin{document}

\[ ^ \]


\end{document}

Produces the error

! Missing { inserted.
<to be read again> 
                   $
l.5 \[ ^ \]

As the end of display math is taken inside the superscript and TeX's grouping is messed up.

With two ^^ you get no error and a single \`` typeset as^^ ` is control-space that is character 32+64=96 which is an open quote in TeX's default OT1 encoding.

With three ^^^ you get

! Text line contains an invalid character.
l.5 \[ ^^^

as in text mode as control-^ is set as an invalid control character.

As in text mode if you add more than three ^ you just get repeats of this behaviour.

| improve this answer | |
6

^ Is a character with many purposes in TeX systems. For the normal usages:

In order to use it to print an exponent you:

  1. Have to be in math mode, i.e. be between \( and \) or $ and $ or \[ and \] or in an environment like equation, etc.

  2. Use it as you normally would.

In order to print a hat over your letter (like ê) you should use either:

  • unicode input (using an utf8 native engine, like Lua/Xe(La)TeX or \usepackage[utf8]{inputenc}
  • use:

    • in text mode \^e
    • in math mode \hat{e}

Single ^ characters are not valid during LaTeX inputs (normally) hence the errors.

EDIT

Examples:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\centering
\^e ê $ e^{x}$

\begin{equation}
\hat{a}=e^{x+1}
\end{equation}

\end{document}

which gives:

enter image description here

Advanced stuff

When ^ is followed by another ^ and:

  • a character of code < 128

or

  • two of the lowercase hexadecimal digits: 0123456789abcdef

then the whole trio/quartet gets replaced by a single character. with the rules found in the TeX Book, chapter 8. (In the millennium edition is pages 46-7)

| improve this answer | |
  • Don't forget the ^^+ usage in the input level processing ;-) – user31729 Apr 18 '17 at 20:03
  • @ChristianHupfer I think is a bit off topic, don't you think? – Moriambar Apr 18 '17 at 20:06
  • No, since you referred to 'with many purposes' ... ;-) It's a completion:-P – user31729 Apr 18 '17 at 20:07
  • Why do you say \^e is not recommended (besides the recommended LaTeX syntax \^{e})? With \usepackage[utf8]{inputenc} \^e and ê is the same – cgnieder Apr 19 '17 at 9:28
  • 1
    @clemens I think that the second one selects the correct font from the font table, using then the kern tables from the font, while the first one manually positions the accent, without consulting the font kern tables. You can see the different results in the image above. – Moriambar Apr 19 '17 at 9:29

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.