Is is possible to allow consecutive subscripts/superscripts? I’m discovering the joy of typing UTF-8 characters easily from my keyboard (thanks bépo) and I’d love to be able to type x²ˣ instead of x^{2x}, however if I define my characters like:
\newunicodechar{²}{^2}
\newunicodechar{ˣ}{^x}
then LaTeX would complain about the fact that I have two consecutive superscripts. Is there a workaround?
MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{newunicodechar}
\newunicodechar{²}{^2}
\newunicodechar{ˣ}{^x}
\begin{document}
$x²ˣ > 0$
\end{document}
²like'to look ahead sox²ˣisx^{2x}but I woudn't – David Carlisle Apr 12 '23 at 16:06A similar algorithm is possible in PDFTeX, but it needs some adaptation because each Unicode character (in UTF-8) corresponds to multiple tokens in PDFTeX. (not included)… but seems like this is an outdated statement. This works great indeed. Is is the solution you had in mind @DavidCarlisle a simpler approach is possible? – tobiasBora Apr 12 '23 at 16:17\newunicodechar{ˣ}{{}^x}is good enough, it depends what you want²ˣto mean – David Carlisle Apr 12 '23 at 16:23x^\primeinstead ofx'? :-P To me,x⁰ ⊕ x¹is easier to read and faster to type thanx^0 \oplus x^1. – tobiasBora Apr 12 '23 at 16:44x¹:-) but that superscript mathematically a 1, I'd want to find it when searching for1in my editor. this does not apply for\primeas that is never used full size – David Carlisle Apr 12 '23 at 16:46x{}^2{}^xisn't an error and may (or may not) be mathematically better thanx^{2x}depending if it is a single superscript or a list of superscript indexes like tensor notation – David Carlisle Apr 12 '23 at 16:55\newunicodechar{ˣ}{{}^x}would not produce an error, my mistake. So the formating is slightly different as it adds a small space, but it’s indeed an interesting simple solution. Note however that it would not handle correctly stuff like2ᵃᵇ_{c}as c would be below the b and not the a. – tobiasBora Apr 12 '23 at 16:58βinstead of\betaemphasis more the meaning. Similarly,\oplusdoes not give any information on the meaning, it only says "put a plus in an o shape", so to me it’s not better than ⊕. Similarly, many symbols have a well established meaning: nobody uses\plus, instead of+: so why can’t I type⊕to denote an addition modulo 2 (XOR) instead of\oplus? Similarly, the integral, sum, product… symbols are well established. And nothing prevents someone interested to change the symbols to redefine ⊕ to print another symbol. – tobiasBora Apr 12 '23 at 20:04