开发者

Latex command with line break

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!


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}%
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜