3

How to write "y^2" in latex ? I need that hook in mathmode. The error says to put the expression within $...$.

cgnieder
  • 66,645
Suman
  • 557
  • @Suman: Beware, all methods provide different output: % arara: pdflatex: { shell: yes } \documentclass{article} \begin{document} y\textasciicircum2 \verb!y^2! $y\string^2$ \end{document} – Johannes_B Jun 29 '14 at 19:06
  • The main question is: why do you want to print the ^ and not use the standard exponent? – egreg Jun 29 '14 at 19:34
  • 3
    @egreg - "[Ours is] not to reason why" (Alfred Lord Tennyson, The Charge of the Light Brigade, 1855). :-) – Mico Jun 29 '14 at 20:57

2 Answers2

13

Here are several methods for showing the ^ character -- in math mode, text mode, and "verbatim" ("monospaced font") mode. (The third text mode variant and the verbatim variant courtesy of cmhughes and Johannes_B...)

enter image description here

\documentclass{article}
\begin{document}
$y\string^2$ --- math mode

y\string^2 --- text mode, variant 1 (same as math mode)

y\^{}2  --- text mode, variant 2

y\textasciicircum 2 --- text mode, variant 3

\verb|y^2| --- monospaced (``verbatim'') font mode
\end{document}
Mico
  • 506,678
1

Here's a little experiment of what you are asking --

\documentclass{article}
\usepackage{tipa}
\usepackage{upgreek}

\begin{document}

$y\string^2$ \\
y\string^2 \\
y\^{}2 \\
y\textasciicircum2\\
\verb!y^2!\\
y\textsuperscript{\^{}}2 \\
$y \mathbin{\char`\^} 2$ \\
$y ^\wedge 2$\\
$y^\bigwedge 2$\\

% requires `tipa` package
y {\textturnv} 2 \\

% one bad idea: use \Lambda
$y ^\Lambda 2$ \\

% update #1: requires `upgreek` package
$y ^\Uplambda 2$
\end{document}

UPDATE

I found this, you may like to have a look.

hola
  • 4,026
  • 3
  • 35
  • 72