Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to automate quotation marks (not quotes) using a macro. Consider the following code:

\newcommand{\mytext}[1]{``#1''}

This one works fine:

\mytext{This is a very long quote. Lorem ipsum dolor sit amet.}

But I want to make my source more readable by placing the text in a new line. The following code produces a space between the opening quotes and the first letter:

\mytext{
  This is a very long quote. Lorem ipsum dolor sit amet.}

Yes, this one will work:

\mytext
  {This is a very long quote. Lorem ipsum dolor sit amet.}

But I would prefer that \mytext would expand to something like this:

\mytext{%
  This is a very long quote. Lorem ipsum dolor sit amet.}

How do I create a % within a \newcommand?

share|improve this question
    
Comments are never tokenized. There's no way to get them inside macros. –  TH. Jan 15 '11 at 6:01
2  
If you want to add quotes with a command, you can use \enquote from the csquotes package, which also handles quotes inside quotes and quotes in other languages. It doesn't remove the space though (neither at the beginning nor at the end), so this isn't really an answer... –  Caramdir Jan 15 '11 at 6:16

1 Answer 1

up vote 16 down vote accepted
\newcommand{\mytext}[1]{``\ignorespaces #1''}
share|improve this answer
    
Very nice. I was thinking about \ignorespaces, but couldn't think where to put it to work. I came up with this elaborate solution involving \afterassignment and tail-recursive macros eating spaces. I'm glad I didn't embarrass myself by posting it! –  TH. Jan 15 '11 at 6:12
4  
If you stick \unskip after #1, then you can remove trailing spaces too (more or less). –  TH. Jan 15 '11 at 6:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.