tags:

views:

55

answers:

2

Hello all,

I am trying to create a command in latex that, when invoked such as \test{\ab}{TEST}, will create a new command defined as \ab[1]{\raggedright TEST: \\ \hspace{0.5in} #1}.

What I am trying to do is something along these lines:

\newchar{\ab}{TEST}
\ab{This is a line TEST says.}

That would execute to yield

TEST:
     This is a line TEST says.

Failing that (which I do hope is possible), I could settle with another command I have drafted. But the issue there is I need a way to place and newline after the text without the user having to specify it.

Thanks ahead for all the help!

+1  A: 

What you want is not completely clear to me, but perhaps:

\newcommand{\ab}[1]{\\
#1:\\
\hspace{4em}This is a line #1 says.}

is a place to start (in particular, your horizontal spacing needs need to be made clearer).

Helpful link.

dmckee
That works as the formatting. But I am looking for a way to have a command that can create new "aliases" of that. Such that I can have "\test" and call that a few times to create "\ab1" "\ab2" "\ab3" (The name determined by what it is "\test" is passed). Sorry if I am not being very clear, this is somewhat difficult to explain :S
Luke Cycon
+2  A: 

Command definitions can be nested; double the # for each level.

\newcommand\newchar[2]{%
  \newcommand #1 [1] {%
    \raggedright #2: \\ \hspace{0.5in} ##1%
  }%
}

Update: Just a comment about the # doubling. This makes more sense when you're defining macros using the \def primitive; in this case, the general construction is something like

\def\foo{%
  \def\bar##1{bar: ##1}%
}
Will Robertson
That is exactly what I was looking for. Funny, nowhere on the internet did I see the part about double #'s for each level. Thanks!
Luke Cycon
Now that I understand the questions, I was just about to suggest trying that. Another day, another thing learned. Very nice.
dmckee