GeneralUse a predefined newcommand in another newcommand.

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Use a predefined newcommand in another newcommand.

Post by centguy »

Can I have

\newcommand{A}{This}

and then
do \newcommand{B}{\A\A} to get \B = ThisThis ??

I tried but it won't work. How can I do to solve this problem? I would like to have a hierarchical way of defining new commands.

Thanks!!

Recommended reading 2024:

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

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

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Use a predefined newcommand in another newcommand.

Post by phi »

This works as requested:

Code: Select all

\documentclass{article}
\newcommand{\A}{This}
\newcommand{\B}{\A\A}
\begin{document}
\B
\end{document}
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Re: Use a predefined newcommand in another newcommand.

Post by centguy »

Great phi !! It is working now.

As someone who always wonder what went wrong, I guess
I have goofed up when I tried something like
\newcommand{\PDF}{A}
\newcommand{\PDFa}{\PDF/a}

I think..

Thanks for the reply ! If not, I would have an ugly layout in my document!
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Re: Use a predefined newcommand in another newcommand.

Post by centguy »

Actually I goofed up again..
\PDFa is working fine. I must have used \PDF1a (which broke the newcommand, I thought the little 'a' will
make LaTeX view PDF1a as a whole unit, but apparently not.), and I believe the true reason is that the newcommand does not like weird
characters. Thanks for the patience if you have followed so far...
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Use a predefined newcommand in another newcommand.

Post by josephwright »

(La)TeX command names are made up of letters, so trying to create anything with a number in will tend to cause problems.
--
Joseph Wright
Joseph Wright
Post Reply