2

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.

1 Answers1

1

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}