GeneralDefinition of new command does not work

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mike-klemin
Posts: 8
Joined: Fri Feb 18, 2011 9:50 pm

Definition of new command does not work

Post by mike-klemin »

I want to define a new command like below

Code: Select all

\newcommand{\my}[1]{\vbox*{{\#1}em}}
When I try \my{2} it only outputs a list of errors like

Code: Select all

! You can't use `\end' in internal vertical mode.
\enddocument ... \endgroup \deadcycles \z@ \@@end
l.37 \end{document}
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
! Missing } inserted.
<inserted text>
}
l.37 \end{document}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
! Extra \endgroup.
<recently read> \endgroup
l.37 \end{document}
Things are pretty mixed up, but I think the worst is over.
)
! Emergency stop.
<*> tables_tex.tex
*** (job aborted, no legal \end found)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Definition of new command does not work

Post by Stefan Kottwitz »

Hi mike-klemin,

did you also define \vbox*, a starred version of \vbox? In standard (La)TeX it's not defined. Without the star it's compilable:

Code: Select all

\newcommand{\my}[1]{\vbox{{\#1}em}}
It would produce the output #1em, since you set a backslash in front of #. This way the argument has no effect. If you omit the backslash you would get 2em by \my{2}:

Code: Select all

\newcommand{\my}[1]{\vbox{{#1}em}}
What would you like to achieve? Could it be that you meant \vspace instead of \vbox? This would produce variable vertical space:

Code: Select all

\newcommand{\my}[1]{\vspace*{#1em}}
Here's the * again, for \vspace it's defined. Note that I removed the inner braces and of course the backslash.

Stefan
LaTeX.org admin
mike-klemin
Posts: 8
Joined: Fri Feb 18, 2011 9:50 pm

Definition of new command does not work

Post by mike-klemin »

Hello Stefan,
I seen you post a lot of useful replies and prayed Ill get one too :)

Yes, I am not sure why did I wrote vbox*... I spent all morning this Sunday, to understand WTF it's not working...well from the bright side I discovered many other thing doing so.

Actually, I want to define a new command which will produce a table, and in that table I had to use vspace*-es to achieve proper alignment (the problem is that if I have a \multirow then I have no way (Or i could not find) to vertically align image in spanned cell I posted it there).
If you could help me there, please?
The table should looks like this
Image
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Definition of new command does not work

Post by Stefan Kottwitz »

Ok, I'll have a look at the other topic!

Stefan
LaTeX.org admin
Post Reply