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
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
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}}} \\}}
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