1

I spend 8 hours in solving this, made some progress but now face the enormous difficulties with verbatim stuff in latex. Any help would be great!

My aim: the todonotes package offers an inline option, which however breaks if one wants to use \listoftodos, because more complex inline things like equation environments are not suitable somehow for the caption argument. An easy solution is to set the optional caption argument of \todo fix to somthing like \todo[inline,caption={inline...}]{...}. The harder but better solution would be to e.g. cut of the first 20 chars of the inline comment and put it into the caption. This is what I tried and which works almost.

Concretely, it already works as long as the cutted version includes no special characters it seems. In the below code you find %%%%%%% marking the decisive place. \StrLeft{\myraw}{10} works, but \StrLeft{\myraw}{20} breaks already.

Additionally I put in some other trials how to make this content verbatime-like. They work outside \newcommand, but not inside. I also know about \NewDocumentCommand{\myverb}{+v}{\texttt{#1}} from xparse, however also here I found no way to achieve what I want.

Looking forward to your help.

\documentclass{article}

\usepackage{xstring}
\usepackage{amsmath}
\usepackage{comment}
\usepackage{todonotes}
\usepackage{verbdef}


% TODO this still does not work for special sequences! kind of escape inbetween?
\newcommand{\MYTODO}[2][]{%
% makes a raw approximation and cut - this must be called within the same newcommand and cannot be outsourced for some reason I do not fully understand:
\scancs[0]\myraw{#2}
%equivalent to:
%\StrExpand[0]{#2}{\h}
%\def\raw{\detokenize\expandafter{\h}}
\StrLeft{\myraw}{10}[\myleft]  %%%%%%% changing this number to for example 20 breaks the code %%%%%%%
%
% this is the essential thing we want:
%\expandafter\verbdef\expandafter\variable\expandafter+\myleft+    %%%breaks immedidiately
%\todo[inline, caption={\string\myleft}, #1]{#2}   %%%breaks immediately
%\todo[inline, caption={\texttt{\myleft}}, #1]{#2}  %%%breaks also for surroundings
\todo[inline, caption={\myleft}, #1]{#2}
}


\begin{document}
\listoftodos
\bigskip

\MYTODO[author=me]{ABCDEF}

\MYTODO{%
but what if
\begin{align*}
    x^2
\end{align*}
}


\bigskip
%I tested here some ways to get verbatime output inside a variable, but both do not work in commands
\def\toverb{this works|, but only outside a newcommand.}
\expandafter\verb\expandafter+\toverb+
\expandafter\verbdef\expandafter\fromverb\expandafter+\toverb+
\fromverb

\end{document}

Output of the code for \StrLeft{\raw}{10}

  • Could you explain what you would hope the output to look like? – Steven B. Segletes Feb 11 '16 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.