Latex Line Break Command

I'm trying to create a latex command that, when called, for example, \test{\ab}{TEST} , will create a new command defined as \ab[1]{\raggedright TEST: \\ \hspace{0.5in} #1} .

What I'm trying to do is something like that:

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

This will run to get

 TEST: This is a line TEST says. 

Otherwise (I hope, perhaps), I could agree with another team that I developed. But the problem there is that I need a way to place a new line after the text without having to indicate it to the user.

Thanks for the help!

+4
source share
2 answers

Command definitions can be nested; twice # for each level.

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

Update: just a comment about doubling # . This makes sense when you define macros with the \def ; in this case, the overall design is something like

  \ def \ foo {%
   \ def \ bar ## 1 {bar: ## 1}%
 }
+2
source

What you want is not entirely clear to me, but it is possible:

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

- This is the place to start (in particular, it is necessary that your horizontal intervals are clearer). A.

Useful link.

+1
source

All Articles