Generalnewcommand # for arguments produces error

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
MannersA
Posts: 2
Joined: Wed Mar 04, 2015 12:28 pm

newcommand # for arguments produces error

Post by MannersA »

Hi,

I am trying to write a newcommand which relies on more than one argument so it contains #1 and #2:

\newcommand{\mpout}[2]{\begin{center}\color{blue}{#1}\end{center}}{\vspace{-25pt}{\hfill {\bf{#2}}} \\}

However this produces this error:

latex> ! You can't use 'macro parameter character #' in horizontal mode.

I understand that # is a special character for writing macros but I don't know how to get around this! Help?!

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

newcommand # for arguments produces error

Post by ignasi »

I think the problems come from a wrong placed }.
Does

Code: Select all

\newcommand{\mpout}[2]{\begin{center}\color{blue}{#1}\end{center}{\vspace{-25pt}{\hfill {\bf{#2}}} \\}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
what you want?
MannersA
Posts: 2
Joined: Wed Mar 04, 2015 12:28 pm

Re: newcommand # for arguments produces error

Post by MannersA »

Yes it does! Thank you so much for your help!
Post Reply