保留命令参数中的换行符

保留命令参数中的换行符

我正在使用来自的 pdfpcnotes.sty 样式https://github.com/cebe/pdfpc-latex-notes我目前正在尝试让它保留换行符,即如果我写

\pnote{
  * Foo
  * Bar
}

我希望它能给我两行注释。我尝试了以下方法:https://tex.stackexchange.com/a/211907但我不得不承认,这种魔法有点超出我的 LaTeX 技能。据我所知,换行符和制表符被重新定义,以便它们可以被参数捕获......?我想到的是:

[... stuff from pdfpcnotes.sty ...]

% Create the magical "dont swallow newlines" command..?
\makeatletter
\def\activateCtrlChars{%
  \catcode`\^^I=\active
  \catcode`\^^M=\active
  \begingroup\lccode`~=`\^^I\lowercase{\endgroup\def~}{&}%
  \begingroup\lccode`~=`\^^M\lowercase{\endgroup\def~}{\\}%
}
\begingroup
\obeylines
\gdef\gobbleLineBreak{\@ifnextchar^^M{\@gobble}{}}%
\endgroup%
\makeatother

% open file on \begin{document}
[... output header ...]
% define a # https://tex.stackexchange.com/a/37757/10327
[...]


\def\lastframenumber{0}

% This is the command that will be used. It first opens a group, then
% switches it into "dont swallow ctrl characters" mode, and then calls
% an auxiliary command that should then receive the newlines...
\newcommand{\pnote}{%
  \begingroup\activateCtrlChars\fetchPnoteArg
}

% The auxiliary command that should receive the newlines
\newcommand{\fetchPnoteArg}[1]{%
    \gobbleLineBreak

    % keep normal notes working
    \note{#1}%

    % if frame changed - write a new header
    [... uninteresting ...]

    % write note to file
    \wlog{========================================}
    \wlog{\unexpanded{#1}}
    \wlog{========================================}
    \immediate\write\pdfpcnotesfile{\unexpanded{#1}}%

    \endgroup
}

但是,这仍然将所有内容放在一行中。:( 有谁知道为什么它在我的情况下不起作用?

多谢!

相关内容