Question

I use the \todo command from the \todonotes package. I'd like to layout my source to put \todos separately from the previous paragraph:

Some text.

\todo{make note}

But I don't want \todo to start a new paragraph, or it screws up the spacing of the document.

Is there a command to avoid this?

If there were a command/package to consume the whitespace up to it, then I could redefine \todo to use it.

Edit: Adding a % between everything is obviously very irritating. Anything else?

Was it helpful?

Solution

I have to agree with everybody else that you should probably just add the %, but I do find this question interesting. The problem is that as soon as LaTeX reads the empty line, it gets converted into the \par command, which ends the previous paragraph. At the beginning of \todo, that \par command has already been executed, and it's impossible to undo it (I think). So your only hope is to keep that \par from being inserted or from behaving like it normally does. If you want to prevent it from being inserted, you could try reading Chapter 8 of "The TeXbook", which should tell you how an empty line is converted to \par. Alternatively, you could try to make a solution based on the following kind of idea:

Some text.{\let\par\relax

\todo{make note}}

But watch out! You definitely don't want to globally change the behavior of \par, which is why I added an extra pair of curly braces (LaTeX commands are scoped, so the new definition of \par only takes effect within the group where the definition was made). Good luck.

OTHER TIPS

When the macro precedes the unwanted space, the % is not necessary if you make use of \@ifnextchar and \@gobble.

Consider something like (in the preamble, of course):

\makeatletter
\let\oldtodo\todo
\renewcommand\todo[1]{%
\oldtodo{#1}%
\@ifnextchar\par{\@gobble}{}}
\makeatother

That way, if you have something like:

\todo{Stuff}

Things

it will act the same as

\todo{Stuff}
%
Things

or

\todo{Stuff}
Things

You can generalize such things with a macro like

\makeatletter
\newcommand\gobblepars{%
    \@ifnextchar\par%
        {\expandafter\gobblepars\@gobble}%
        {}}
\makeatother

You can then use \gobblepars wherever you want to eat space (like after the todo). You can also re-define todo (as shown above) to automatically place a \gobblepars after it.

To handle the leading empty space. you can use \gobblepars too, but you have to be explicit. For example:

Some text\gobblepars

\todo{Stuff}

will prevent a \par from showing up between the two lines.

Try this:

Some text.
%
\todo{make note}

may be you shouldn't leave new line between the text and the todo note or just comment it

Some text.
%
\todo{make note}

How about

Some text.
%
\todo{make note}
%
some more text

Set \endlinechar=-1 to make empty lines have no effect. You will need to use \par to separate paragraphs, which I think is a bigger irritation than having to type % on separator lines, but that's what you're asking for.

How about keeping everything that still has work left to do inside \def tags, and then removing it and moving it into the document proper when there's no more work to do?

E.g.

\def \par1
{
It was the best of times, it was the
}

\def \par2000
{
"Repression is the only lasting philosophy. The dark deference of fear and slavery, my friend," observed the Marquis
}

\def \paridunno
{
The end
}

A Tale of Two Cities, by Charles Dickens

\par1
\todo{write a whole bunch of pages}
\par2000
\todo{Visit ghost of Christmas future, copy pages from finished book}
\paridunno
\todo{Think of a better ending}

That has the added benefit of giving you a \listoftodos both in the source literally, and

in the output.

just include your \todo right in the middle of your text. no line break, no nothing.

blah blah blah text \todo{Do this now!} more text blah blah blah.

on my computer (win xp, miktex 2.7, texniccenter) this work fine, produces no line break, and puts the todo note in the margin. . .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top