# Shortcut for command without braces

I want to create a shortcut for

\textsubscriptARGS

With ARGS being any number.

I want to type something like 123\a33332 and have the same output as 123\textsubscript{33332}

I tried with \def and \newcommand unsuccessfully Thanks!

I tryed \def\aa #1#2#3{\textsubscript{#1#2#3}} and it works but only if there are 3 args, do you know how to set the args as optional or to include all the characters before a space as one arg?

• Should it handle decimals as well, or only whole numbers? What about negative numbers? What is the delimiter that identifies the end of this number... a space? What if you have a sentence-ending 123\a33332.? – Werner Apr 20 '17 at 1:55
• Welcome to the site =) There are some wizards here who might come along and blow me away, but I'm really not optimistic, braces are what LaTeX uses to delimit arguments. Making 123\a{33332} work is easy as pie (although it might be better to pick a different name to \a) But what you are trying to do flies so roundly in the face of how LaTeX works that there are better things to do with your time, like finding an editor that can help you with subscripts – Au101 Apr 20 '17 at 1:56
• @Werner and how will LaTeX tell argument from command \a3 will be read as one command won't it? – Au101 Apr 20 '17 at 1:57
• @Au101: Numbers are not allowed in control sequences (by default, unless defined using \csname...\endcsname). – Werner Apr 20 '17 at 1:58
• @rusty: That will only work if you always have 3 numbers. That is, \aa123 would be fine, but \aa1234 would not work as expected. The same goes for \aa12. – Werner Apr 20 '17 at 2:04

This has all kinds of wrong written over it:

\documentclass{article}

\usepackage{xspace}
\def\aa#1 {\textsubscript{#1}\xspace}

\begin{document}

Here is some 123\aa4 text together with
some 123\aa45 text together with
some 123\aa456 text together with
some 123\aa4567 text together with
some 123\aa45678 text together with
some 123\aa456789 text together with
some 123\textsubscript{4567890}.

\end{document}


Why?

• \aa is already defined (as the Swedish letter å).

• There is no consistency in usage for \aa at the end of a sentence, since \def's parameter text requires a space as the ending delimiter for its argument. Conditioning on a . would be okay, but what happens with ,, or !, or ?, or ...

• In the words of Doctor Who "Many things about this are not good" :P Good job though, I'm actually surprised it was that easy! =) – Au101 Apr 20 '17 at 2:18
• As a Scandinavian I take offence to calling \aa the ångström symbol ;-) – daleif Apr 20 '17 at 7:06
• @daleif. If you want the actual letter Å, you should probably type that directly, while using \aa for the symbol. Similar to how TeX does not support \Alpha, because it doesn't make sense to use that as a symbol, and if you want it as a letter, you should just type the actual letter. (Disclaimer: I have no idea what I'm talking about. I read this site a lot, but don't actually use TeX myself.) – TRiG Apr 20 '17 at 9:23
• @TRiG \aa is not Å (that is \AA), \aa is å, and both is a vowel used in Scandinavia. – daleif Apr 20 '17 at 9:39
• In western Danish dialect you can do entire meaningful sentences entirely in vowels. – daleif Apr 20 '17 at 17:50

If you just want integers, you might do as follows:

\documentclass{article}
\usepackage{xspace}

\newcommand{\wrongwaytodosubscripts}{%
\afterassignment\wwtdss\count255=
}
\def\wwtdss{\textsubscript{\the\count255}\xspace}

\begin{document}

123\wrongwaytodosubscripts123 followed by whatever.

123\wrongwaytodosubscripts123.

\end{document}


Whether I recommend doing it should be clear from the macro name I chose.

Don't do like this! It's error prone and has several limitations.