# Create newcommand where every argument has multiple characters

How can I create a newcommand (for latex preamble, using lyx) which its arguments are more than one character?

Specifically, I'm trying to create myself a shortcut for the Rank–nullity theorem and tried to set the following latex preamble I wrote: (I've set \Ima command to Im text)

\newcommand{\dimthm}[2]{\dim{#1}=\dim{\Ima{#2}}+\dim{\ker{#2}}}


It works fine if every argument is only one character: \dimthm VT will produce:

dim V = dim Im T + dim ker T


But if for example my transformation is LALA I won't be able to get

dim V = dim Im LALA + dim ker LALA


Is it possible?

I've saw a few similar question over here, but couldn't make any solution work.

• You know that you should use \dimthm{VT} then? Otherwise TeX/LaTeX just reads the V and ignores the T as macro argument to \dimthm – user31729 Mar 24 '17 at 17:16
• Oh you're right, I just automatically wrote it as I use the command in Lyx editor. – arieljannai Mar 24 '17 at 17:21
• which proves that such editors LyX lead to lazyness ;-) – user31729 Mar 24 '17 at 17:24
• Which editor do you recommend? I just started with LyX since I heard of it and I was short in time to learn and needed to start quickly – arieljannai Mar 24 '17 at 17:28
• I don't recommend those editors at all. Use vi or emacs or notepad etc. – user31729 Mar 24 '17 at 17:32

Grouping with braces should help. In this way, V is the first argument and LALA is the second. However, one must remember that something like LALA will typeset as four consecutive math variables L, A, L, A.

\documentclass{article}
\def\Ima{\mathrm{Im}}
\newcommand{\dimthm}[2]{\dim{#1}=\dim{\Ima{#2}}+\dim{\ker{#2}}}
\begin{document}
$\dimthm VT$

$\dimthm V{LALA}$

$\dimthm {Howdy}{Ho}$
\end{document}