LaTeX Beginner's Guide ⇒ Some quick notation questions about newcommand
Some quick notation questions about newcommand
There are a couple of quick questions I have. I have seen a couple of \newcommand codes:
1. \newcommand\routine[4]{
2. \newcommand*\routine[4]{
3. \newcommand\rountine{%
As usual, I can't find anything on the net about a distinction. For all of the applications I've been working with, they seem to work identically, but I'm sure there's some kind of difference between them.
Thanks!
-Dan
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
-
- Posts: 707
- Joined: Tue Mar 25, 2008 5:02 pm
Some quick notation questions about newcommand
\newcommand\routine[4]{}
will define a "long" command "\routine" that has four arguments. The starred version does the same except the command is not "long" (i.e., the four arguments cannot contain paragraph breaks). If your command works with the star, you should use the star.Your last example simply defines "\rountine" but expects no arguments (and thus it won't eat the four arguments following it like the other two will).
Some quick notation questions about newcommand
Thank you!kaiserkarl13 wrote:\newcommand\routine[4]{}
will define a "long" command "\routine" that has four arguments. The starred version does the same except the command is not "long" (i.e., the four arguments cannot contain paragraph breaks). If your command works with the star, you should use the star.
Your last example simply defines "\rountine" but expects no arguments (and thus it won't eat the four arguments following it like the other two will).
Actually, I had meant to ask about
\newcommand\routine[4]{%
My question was about why we would need the %. All it does is tell the compiler that what follows on the line is not code, right? So why does it keep cropping up? I would think that \newcommand\routine[4]{ would be enough.
Thanks again!
-Dan
-
- Posts: 707
- Joined: Tue Mar 25, 2008 5:02 pm
Some quick notation questions about newcommand
Code: Select all
\documentclass{article}
\newcommand*{\hello}{
Hello, world!}
\newcommand*{\goodbye}{%
Goodbye, world!}
\begin{document}
\noindent
This is the \hello\ command. Saying\hello\ is what we are doing.
This is the \goodbye\ command. Saying\goodbye\ is what we are doing.
\end{document}
Code: Select all
\newcommand*{\hello}{\relax
Hello, world!}
Code: Select all
\newcommand*{\hello}{Hello, world!}