% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*dummy>
I'd like to keep this part here for later use.
%</dummy>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input l3docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
Copyright (C) 2016-2026, Ruini Xue <xueruini@gmail.com>

It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
this license or (at your option) any later version.  The latest
version of this license is in the file:

   http://www.latex-project.org/lppl.txt
\endpreamble
\postamble

This work is "maintained" (as per LPPL maintenance status) by
  Ruini Xue.

This work consists of the file  zebra-goodies.dtx
          and the derived files zebra-goodies.ins,
                                zebra-goodies.pdf and
                                zebra-goodies.sty.

\endpostamble
\usedir{tex/latex/zebra-goodies}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\nopreamble\nopostamble
\generate{
  \file{\jobname-demo-twocol.tex}{\from{\jobname.dtx}{demo-twocol}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/zebra-goodies}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
%\nopreamble\nopostamble
%\usedir{doc/latex/zebra-goodies}
%\generate{
%  \file{README.md}{\from{\jobname.dtx}{dummy}}
%}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*driver|package>
%\RequirePackage{xparse}
%</driver|package>
%<*driver>
\documentclass[full]{l3doc}
\usepackage[scaled=0.93]{helvet}
\usepackage[final]{listings}
\usepackage{graphicx}
\graphicspath{{./out/}}
\usepackage{zebra-goodies}
\colorlet{mycyan}{cyan}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\makeatletter
%
%^^A For creating examples with nice highlighting of code, and so
%^^A on; based on the system used in the listings source (lstsample).
%\lst@RequireAspects{writefile}
%\newsavebox{\LaTeXdemo@box}
%\lstnewenvironment{LaTeXdemo}[1][code and example]{^^A
%  \global\let\lst@intname\@empty
%  \expandafter\let\expandafter\LaTeXdemo@end
%    \csname LaTeXdemo@#1@end\endcsname
%  \@nameuse{LaTeXdemo@#1}^^A
%}{^^A
%  \LaTeXdemo@end
%}
%\newcommand*\LaTeXdemo@new[3]{^^A
%  \expandafter\newcommand\expandafter*\expandafter
%    {\csname LaTeXdemo@#1\endcsname}{#2}^^A
%  \expandafter\newcommand\expandafter*\expandafter
%    {\csname LaTeXdemo@#1@end\endcsname}{#3}^^A
%}
%\newcommand*\LaTeXdemo@common{^^A
%  \setkeys{lst}{
%    basicstyle      = \small\ttfamily,
%    %basewidth      = 0.51em,
%    frame           = l,
%    backgroundcolor = \color{gray!5},
%    gobble          = 3,
%    keywordstyle    = \bfseries\color{blue},
%    language        = [LaTeX]{TeX},
%    moretexcs       = {
%      todo            ,
%      note            ,
%      comment         ,
%      fixed           ,
%      placeholder     ,
%      question        ,
%      zebratodo       ,
%      zebranote       ,
%      zebracomment    ,
%      zebrafixed      ,
%      zebraplaceholder,
%      zebranewnote    ,
%      colorlet
%    }
%  }^^A
%}
%\newcommand*\LaTeXdemo@input{^^A
%  \MakePercentComment
%  \catcode`\^^M=10\relax
%  \small
%  \begingroup
%    \setkeys{lst}{
%      SelectCharTable=\lst@ReplaceInput{\^\^I}{\lst@ProcessTabulator}
%    }^^A
%    \leavevmode
%      \input{\jobname.tmp}^^A
%  \endgroup
%  \MakePercentIgnore
%}
%\LaTeXdemo@new{code and example}{^^A
%  \setbox\LaTeXdemo@box=\hbox\bgroup
%    \lst@BeginAlsoWriteFile{\jobname.tmp}^^A
%    \LaTeXdemo@common
%}{^^A
%    \lst@EndWriteFile
%  \egroup
%  \begin{center}
%    \ifdim\wd\LaTeXdemo@box>0.48\linewidth\relax
%      \hbox to\linewidth{\box\LaTeXdemo@box\hss}^^A
%        \begin{minipage}{\linewidth}
%          \LaTeXdemo@input
%        \end{minipage}
%    \else
%      \begin{minipage}{0.48\linewidth}
%        \LaTeXdemo@input
%      \end{minipage}
%      \hfill
%      \begin{minipage}{0.48\linewidth}
%        \hbox to\linewidth{\box\LaTeXdemo@box\hss}^^A
%      \end{minipage}
%    \fi
%  \end{center}
%}
%\LaTeXdemo@new{code only}{^^A
%  \LaTeXdemo@common
%}{^^A
%}
%
%\providecommand*\opt[1]{\texttt{#1}}
%
%\makeatother
%
%\GetFileInfo{\jobname.sty}
%
%\changes{v0.1.0}{2017/07/05}{Initial public release}
%\changes{v0.2.0}{2017/11/26}{Fix \pkg{xcolor} conflict}
%\changes{v0.3.0}{2017/12/06}{Detect command conflicts}
%\changes{v0.4.0}{2019/06/29}{Show note number for easy reference}
%\changes{v0.5.0}{2019/06/29}{Use darker color for label}
%\changes{v0.6.0}{2019/06/30}{Use gray background for label}
%\changes{v0.9.0}{2026/02/25}{Fix margin placement, drop tikz, fix counter in moving args, modernize to kernel key-value and NewDocumentCommand}
%\changes{v0.9.1}{2026/02/27}{Beautify the numbers.}
%\changes{v0.9.2}{2026/03/03}{Faster.}
%\changes{v1.0.0}{2026/03/16}{\pkg{expl3}, list of notes and compatibility.}
%
%\title{^^A
%  \pkg{zebra-goodies} --- Easy Notes Taking^^A
%    \thanks{^^A
%      This file describes version \fileversion, last revised
%      \filedate.^^A
%    }^^A
%}
%\author{^^A
%  Ruini Xue\thanks{E-mail: xueruini@gmail.com}^^A
%}
%\date{Released \filedate}
%
%\maketitle
%
%\begin{abstract}
%  The \pkg{zebra-goodies} package provides a lightweight set of macros for
%  inline note-taking during document writing. It is designed to be simple and
%  practical for both solo and collaborative workflows.
%  Five built-in commands---\cs{todo}, \cs{comment}, \cs{note}, \cs{fixed},
%  and \cs{placeholder}---cover common use cases out of the box, and
%  \cs{zebranewnote} lets you define additional note types as needed.
%  Notes are automatically numbered per type, marked with a \cs{dbend} symbol
%  in the nearest margin, and summarised with a summary table plus a detailed
%  note list at the end of the document.
%  Passing the \opt{final} option suppresses all notes for production output.
%\end{abstract}
%
%\tableofcontents
%
%\begin{documentation}
%
%\section{Introduction}
%
% Many note-taking and to-do packages exist for \LaTeX{}, but most fall into
% one of two traps: they either offer an overwhelming feature set that tries to
% cover every conceivable use case, or they clutter the margins with oversized
% colourful boxes and arrows that make the document hard to read.
%
% \pkg{zebra-goodies} takes a different approach. It aims to be \emph{simple}
% ---intuitive commands with only the arguments you actually need---and
% \emph{good enough}---notes appear inline with a small visual cue in the
% margin, keeping the document readable while still making annotations easy to
% spot. Each note type is automatically numbered, and a summary table plus a
% detailed note list at the end of the document serve as a gentle reminder to
% address them before the final version.
%
% The package requires \LaTeX{} 2022-06-01 or later.
%
%\section{Installation}
%
%\changes{v0.7.0}{2019/07/01}{Move to docstrip}
%
% The package is supplied in \file{dtx} format and as a pre-extracted zip file.
% The latter is the most convenient option for most users: simply unzip it into
% your local texmf directory and run \texttt{texhash} to update the file-name
% database, or unzip the files directly into your working directory. To unpack
% the \file{dtx} yourself, run \texttt{tex \jobname.dtx} to extract the package,
% or \texttt{latex \jobname.dtx} to extract it and typeset the documentation at
% the same time.\footnote{Running \texttt{latexmk \jobname.dtx} is even more
% convenient as it handles multiple compilation passes automatically.}
%
%\section{Using the package}
%
% Load the package in the preamble with any desired options.
%\begin{LaTeXdemo}[code only]
%  \usepackage[<options>]{zebra-goodies}
%\end{LaTeXdemo}
%
%\subsection{Package Options}
%\label{sec:options}
%
%\DescribeOption{draft}
%\DescribeOption{final}

% These two options are complementary. By default \opt{draft} is active:
% all notes are typeset inline and a summary table plus a detailed note list are appended
% at the end of the document. Setting \opt{final} (or |draft=false|) suppresses
% all notes and the generated lists, producing clean output ready for
% distribution.
%
%\DescribeOption{microtypeexpansion}
% Controls whether \pkg{microtype} is loaded with font expansion enabled.
% Default: \texttt{true}. Set |microtypeexpansion=false| or use the
% complementary option \opt{nomicrotypeexpansion} to disable expansion while
% keeping \pkg{microtype} loaded. \pkg{zebra-goodies} ensures
% \pkg{microtype} is loaded. Engines without font expansion support still fall back to
% |expansion=false| automatically.
%
%\DescribeOption{hyperref}
% Controls whether the \pkg{hyperref} package is loaded by \pkg{zebra-goodies}.
% Default: \texttt{true}. Set |hyperref=false| or use the complementary option
% \opt{nohyperref} to disable automatic loading.
%
%\DescribeOption{listofnotes}
% Controls whether the summary table and detailed note list are printed at the
% end of the document. Default: \texttt{true}. Set |listofnotes=false| or use
% the complementary option \opt{nolistofnotes} to suppress them.
%
%\subsection{Notes Macros}
%\begin{function}{\todo}
%  \begin{syntax}
%    \cs{todo}\oarg{name}\marg{note content}
%  \end{syntax}
%\end{function}
%
%  The primary command provided by \pkg{zebra-goodies} is \cs{todo}. It inserts
%  an inline note in the current paragraph, typeset in a predefined colour and
%  marked with a \cs{dbend} symbol in the nearest margin. The mandatory
%  \meta{note content} describes the task; the optional \meta{name} specifies
%  who is responsible for addressing it, which is particularly useful during
%  collaborative writing.
%
% \begin{LaTeXdemo}
%   A very simple example of a todo note \todo{how should we go to the lake?},
%   and the result will be presented right below the code snippet. Please
%   compare the code and the result.
% \end{LaTeXdemo}
%
% The following example shows how to assign notes to specific people.
% Notes of the same type are numbered sequentially, and assignees are
% prefixed with \texttt{@}.
%
% \begin{LaTeXdemo}
%   Another one with an assignee is like \todo[tom]{you should buy the ticket},
%   and you will find the same type of notes are numbered. And the assignees are
%   being \texttt{@}-ed right before the text. And another one with many
%   assignees \todo[lucy, jessie, tom]{prepare the foo}.
% \end{LaTeXdemo}

%  Because notes are set as inline text, they work inside moving arguments
%  such as \cs{section} and \cs{caption} without issues.
%
%  \begin{LaTeXdemo}[code only]
%    \section{Introduction\todo[jerry]{please figure out a better name}}
%    \begin{figure}
%      \centering
%      \caption{Speed vs distance. \todo{need to insert the figure}}
%    \end{figure}
%  \end{LaTeXdemo}
%
%\begin{function}{\note}
%  \begin{syntax}
%    \cs{note}\oarg{name}\marg{note text}
%  \end{syntax}
%\end{function}
%\begin{function}{\comment}
%  \begin{syntax}
%    \cs{comment}\oarg{name}\marg{comment text}
%  \end{syntax}
%\end{function}
%\begin{function}{\fixed}
%  \begin{syntax}
%    \cs{fixed}\oarg{name}\marg{fixed text}
%  \end{syntax}
%\end{function}
%\begin{function}{\placeholder}
%  \begin{syntax}
%    \cs{placeholder}\oarg{name}\marg{placeholder text}
%  \end{syntax}
%\end{function}
%  These commands share the same syntax and behaviour as \cs{todo}; they
%  differ only in name and colour, providing semantic distinction for
%  different annotation purposes.
%
%  If any of these short names conflicts with another loaded package,
%  \pkg{zebra-goodies} will \emph{not} overwrite the existing definition.
%  Instead, it issues a warning and you should use the prefixed form
%  (e.g.\ \cs{zebracomment} instead of \cs{comment}).
%  The following example mixes several note types. Note that
%  \cs{zebracomment} is used here because \cs{comment} is already defined
%  by \pkg{l3doc}.
%  \begin{LaTeXdemo}
%    We may want to reorganise \note{how should we structure the intro?} this
%    part before the final submission. The experimental setup in Section~2 has
%    already been reviewed by a collaborator \zebracomment[tom]{the setup
%    description looks clear now}. Results are presented in the following
%    tables and figures, but some of them are still missing
%    \placeholder[lucy, tom]{insert Figure~3 here}. The discussion section
%    has been revised and all previous issues addressed \fixed[John]{updated
%    the conclusion}. Finally, the list of references needs a second pass
%    before we can submit \todo{check bibliography entries for formatting}.
%    With these items resolved, \note[who]{anything else?} the draft should
%    be ready to go.
%  \end{LaTeXdemo}
%
%\begin{function}{\zebratodo}
%  \begin{syntax}
%    \cs{zebratodo}\oarg{name}\marg{note text}
%  \end{syntax}
%
%  Each built-in note command has a prefixed alias that is always available,
%  regardless of name conflicts. If \cs{todo} is already taken by another
%  package, use \cs{zebratodo} instead. The same applies to all other types.
%\end{function}
%\begin{function}{\zebranote}
%  \begin{syntax}
%    \cs{zebranote}\oarg{name}\marg{note text}
%  \end{syntax}
%\end{function}
%\begin{function}{\zebracomment}
%  \begin{syntax}
%    \cs{zebracomment}\oarg{name}\marg{comment text}
%  \end{syntax}
%\end{function}
%\begin{function}{\zebrafixed}
%  \begin{syntax}
%    \cs{zebrafixed}\oarg{name}\marg{fixed text}
%  \end{syntax}
%\end{function}
%\begin{function}{\zebraplaceholder}
%  \begin{syntax}
%    \cs{zebraplaceholder}\oarg{name}\marg{placeholder text}
%  \end{syntax}
%\end{function}
%
%\begin{function}{\zebranewnote}
%  \begin{syntax}
%    \cs{zebranewnote}\marg{note name}\marg{xcolor name}
%  \end{syntax}
%  Creates a new note type. The \meta{note name} becomes the command name
%  (e.g.\ passing |question| creates \cs{question} and \cs{zebraquestion}),
%  and \meta{xcolor name} sets its colour. The colour must be a named colour
%  already known to \pkg{xcolor}; define it with \cs{definecolor} or
%  \cs{colorlet} beforehand if needed.
%  \changes{v0.8.0}{2019/07/04}{Fix new note demo}
%  \changes{v0.8.1}{2019/07/04}{Fix doc}
%  \begin{LaTeXdemo}
%    \colorlet{mycyan}{cyan}
%    \zebranewnote{question}{mycyan}
%    When it moves to the next step, we should be fine. \question[who]{what's this?}
%  \end{LaTeXdemo}
%\end{function}
%
%\subsection{Two-column Support}
%
% In \texttt{twocolumn} documents, the \cs{dbend} symbol is automatically
% placed on the nearest margin: left margin for the left column, right margin
% for the right column. No special configuration is needed like this:
%
% \begin{center}
%   \fbox{\includegraphics[width=0.9\linewidth,page=1]{zebra-goodies-demo-twocol}}
% \end{center}
%
% It is generated with the following code.  This also works correctly in combination
% with the \texttt{twoside} option.
% \lstinputlisting[
%   basicstyle=\small\ttfamily,
%   frame=l,
%   backgroundcolor=\color{gray!5},
%   firstline=3, ^^A docstrip adds 2 more lines
%   keywordstyle=\bfseries\color{blue},
%   language={[LaTeX]TeX},
%   moretexcs={todo,note,comment,fixed,placeholder},
% ]{\jobname-demo-twocol.tex}
%
%
%\section{Predefined Colours}
%
% The package also defines a small palette of named colours intended for use
% with \pkg{pgfplots} or other drawing packages:
% \begin{itemize}
% \item \textcolor{zebrablue}{\texttt{zebrablue}}
% \item \textcolor{zebrared}{\texttt{zebrared}}
% \item \textcolor{zebrayellow}{\texttt{zebrayellow}}
% \item \textcolor{zebrapurple}{\texttt{zebrapurple}}
% \item \textcolor{zebragreen}{\texttt{zebragreen}}
% \end{itemize}
%
%\end{documentation}
%
%\begin{implementation}
%
%\section{Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<@@=zebra>
%    \end{macrocode}
%
% Version data to start with.
%    \begin{macrocode}
\ProvidesExplPackage{zebra-goodies}
  {2026/03/16}
  {1.0.0}
  {Easy Notes Taking}
%    \end{macrocode}
%
%\subsection{Package options}
%
% Four package options \opt{draft}, \opt{microtypeexpansion}, \opt{hyperref},
% and \opt{listofnotes} are created using
% the kernel key--value interface available since \LaTeX{} 2022-06-01.
%    \begin{macrocode}
\bool_new:N \l@@_draft_bool
\bool_new:N \l@@_microtypeexpansion_bool
\bool_new:N \l@@_hyperref_bool
\bool_new:N \l@@_listofnotes_bool
\seq_new:N \g@@_note_types_seq
\prop_new:N \g@@_note_colors_prop
\prop_new:N \g@@_note_public_alias_prop
\int_new:N \g@@_note_id_int
\tl_new:N \l@@_note_target_tl
\tl_new:N \l@@_summary_rows_tl
\int_new:N \l@@_total_notes_int

\msg_new:nnn { zebra } { command-taken }
  {
    The~command~'\iow_char:N\\#1'~is~already~defined.~
    Use~'\iow_char:N\\zebra#1'~instead.
  }

\prg_new_conditional:Npnn \@@_if_package_loaded:n #1 { T , F , TF }
  {
    \cs_if_exist:cTF { ver@#1.sty }
      { \prg_return_true: }
      { \prg_return_false: }
  }

\keys_define:nn { zebra }
  {
    draft .bool_set:N = \l@@_draft_bool,
    draft .initial:n = true,
    final .meta:n = { draft = false },
    microtypeexpansion .bool_set:N = \l@@_microtypeexpansion_bool,
    microtypeexpansion .initial:n = true,
    nomicrotypeexpansion .meta:n = { microtypeexpansion = false },
    hyperref .bool_set:N = \l@@_hyperref_bool,
    hyperref .initial:n = true,
    nohyperref .meta:n = { hyperref = false },
    listofnotes .bool_set:N = \l@@_listofnotes_bool,
    listofnotes .initial:n = true,
    nolistofnotes .meta:n = { listofnotes = false },
  }
\ProcessKeyOptions [ zebra ]
\sys_if_engine_xetex:T
  { \bool_set_false:N \l@@_microtypeexpansion_bool }

\cs_new_protected:Npn \@@_setup_microtype:
  {
    \@@_if_package_loaded:nTF { microtype }
      {
        \bool_if:NF \l@@_microtypeexpansion_bool
          { \microtypesetup { expansion = false } }
      }
      {
        \bool_if:NTF \l@@_microtypeexpansion_bool
          { \RequirePackage{microtype} }
          { \RequirePackage[expansion=false]{microtype} }
      }
  }
\@@_setup_microtype:
\@@_if_package_loaded:nF { hyperref }
  {
    \bool_if:NT \l@@_hyperref_bool
      {
        \RequirePackage{hyperref}
        \hypersetup { pdfborder = { 0 0 0 } }
      }
  }
\RequirePackage{xcolor}
\RequirePackage{marginnote}
\cs_if_exist:NTF \dbend
  {
    \cs_set_eq:NN \@@_saved_dbend: \dbend
    \cs_undefine:N \dbend
    \RequirePackage{manfnt}
    \cs_set_eq:NN \dbend \@@_saved_dbend:
  }
  { \RequirePackage{manfnt} }
\cs_new_protected:Npn \@@_pdfstring_note:
  { \@ifnextchar [ { \@@_pdfstring_note_opt:w } { \use_none:n } }
\cs_new_protected:Npn \@@_pdfstring_note_opt:w [#1] #2 { }
\cs_new_protected:Npn \@@_apply_pdfstring_defs:
  {
    \@@_if_package_loaded:nT { hyperref }
      {
        \pdfstringdefDisableCommands
          {
            \seq_map_inline:Nn \g@@_note_types_seq
              {
                \cs_set_eq:cN { zebra##1 } \@@_pdfstring_note:
                \prop_if_in:NnT \g@@_note_public_alias_prop { ##1 }
                  { \cs_set_eq:cN { ##1 } \@@_pdfstring_note: }
              }
          }
      }
  }
\hook_gput_code:nnn { begindocument } { zebra-goodies }
  { \@@_apply_pdfstring_defs: }
%    \end{macrocode}
%
% \subsection{Main notes macros}
% Various helper macros are defined before reaching out to the \cs{todo} commands.
%
% Place the margin note on the nearest margin. Takes two arguments:
% |#1| for the left margin (number then symbol) and |#2| for the right
% margin (symbol then number), so the symbol always sits closest to the
% text column. In twocolumn mode, \cs{marginpar}'s optional argument
% selects the left-margin variant automatically. In single-column mode,
% \cs{marginnote} is used with the right-margin variant as default.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_margin_note:nn #1#2
  {
    \if@twocolumn
      \mode_if_inner:TF
        { \marginnote{#2} }
        {
          \marginpar
            [ { \makebox[\marginparwidth]{#1} } ]
            { \makebox[\marginparwidth]{#2} }
        }
    \else
      \marginnote[#1]{#2}
    \fi
  }
\cs_new:Npn \@@_target:nn #1#2
  {
    \@@_if_package_loaded:nTF { hyperref }
      { \hypertarget{#1}{#2} }
      {#2}
  }
\cs_new:Npn \@@_link:nn #1#2
  {
    \@@_if_package_loaded:nTF { hyperref }
      { \hyperlink{#1}{#2} }
      {#2}
  }
\cs_new:Npn \@@_prepend:nn #1#2
  { \tl_if_blank:nTF {#2} {} {#1#2} }
\cs_new:Npn \@@_capitalize_type:n #1
  { \text_uppercase:n { \tl_head:n {#1} } \tl_tail:n {#1} }
\cs_new:Npn \@@_note_count:n #1
  { \int_use:c { g@@_note_count_#1_int } }
\cs_new:Npn \@@_note_color:n #1
  { \prop_item:Nn \g@@_note_colors_prop {#1} }
\cs_new_protected:Npn \@@_new_listbody:n #1
  { \tl_new:c { g@@_listbody_#1_tl } }
\cs_new:Npn \@@_use_listbody:n #1
  { \tl_use:c { g@@_listbody_#1_tl } }
\cs_new_protected:Npn \@@_record_note:nnnnnn #1#2#3#4#5#6
  {
    \tl_gput_right:cx { g@@_listbody_#1_tl }
      {
        \exp_not:N \@@_list_entry:nnnnnnn
        { \exp_not:n {#1} }
        { \exp_not:n {#2} }
        {#3}
        { \exp_not:n {#4} }
        { \exp_not:n {#5} }
        {#6}
        { \thepage }
      }
  }
\cs_new_protected:Npn \@@_note:nnnn #1#2#3#4
  {
    \bool_if:NT \l@@_draft_bool
      {
      \int_gincr:c { g@@_note_count_#1_int }
      \int_gincr:N \g@@_note_id_int
      \tl_set:Nx \l@@_note_target_tl
        { zebranote.\int_use:N \g@@_note_id_int }
      \@@_record_note:nnnnnn
        {#1}
        {#2}
        { \@@_note_count:n {#1} }
        {#3}
        {#4}
        { \l@@_note_target_tl }
      \@@_target:nn { \l@@_note_target_tl } {}
      \@@_margin_note:nn
        {\textcolor{#2}{%
          {\bfseries\@@_note_count:n {#1}}\kern1pt\textdbend}}
        {\textcolor{#2}{%
          \textdbend\kern1pt{\bfseries\@@_note_count:n {#1}}}}%
      \textcolor{#2}{[\colorbox[gray]{0.97}{%
          \textcolor{#2!70!black}{%
            \textsc{\MakeLowercase{\MakeUppercase#1}}
            \@@_note_count:n {#1}\texttt{\@@_prepend:nn {@}{#3}}:}} #4]}%
      }
  }
\cs_new_protected:Npn \@@_new_note_type:nn #1#2
  {
    \seq_gput_right:Nn \g@@_note_types_seq {#1}
    \prop_gput:Nnn \g@@_note_colors_prop {#1} {#2}
    \int_new:c { g@@_note_count_#1_int }
    \@@_new_listbody:n {#1}
    \exp_args:Nc \NewDocumentCommand { zebra#1 } { O{} m }
      { \@@_note:nnnn {#1}{#2}{##1}{##2} }
    \@@_if_package_loaded:nT { hyperref }
      { \@@_apply_pdfstring_defs: }
    \cs_if_exist:cTF {#1}
      { \msg_warning:nnn { zebra } { command-taken } {#1} }
      {
        \cs_set_eq:cc {#1} {zebra#1}
        \prop_gput:Nnn \g@@_note_public_alias_prop {#1} { true }
      }
  }
\cs_new_protected:Npn \@@_list_entry:nnnnnnn #1#2#3#4#5#6#7
  {
    \par\noindent
    \textcolor{#2}{%
      \textbf{\@@_capitalize_type:n {#1}~#3}%
      \tl_if_blank:nF {#4} { \enspace \texttt{\@@_prepend:nn {@}{#4}} }}%
    \nobreak\dotfill
    \@@_link:nn {#6} {#7}%
    \par
    \begingroup
      \leftskip=1.5em
      \parindent=0pt
      #5\par
    \endgroup
  }
\cs_new_protected:Npn \@@_print_note_group:n #1
  {
    \int_compare:nNnT { \@@_note_count:n {#1} } > { 0 }
      {
        \par\medskip
        \@@_use_listbody:n {#1}
      }
  }
\cs_new_protected:Npn \@@_summary_row:n #1
  {
    \int_compare:nNnT { \@@_note_count:n {#1} } > { 0 }
      {
        \int_add:Nn \l@@_total_notes_int { \@@_note_count:n {#1} }
        \tl_put_right:Nx \l@@_summary_rows_tl
          {
            \exp_not:N \textcolor
              { \@@_note_color:n {#1} }
              {#1}
            \exp_not:N &
            \@@_note_count:n {#1}
            \exp_not:N \\
          }
      }
  }
\cs_new_protected:Npn \@@_print_notes:
  {
    \tl_clear:N \l@@_summary_rows_tl
    \int_zero:N \l@@_total_notes_int
    \seq_map_inline:Nn \g@@_note_types_seq
      { \@@_summary_row:n {##1} }
    \tl_if_empty:NF \l@@_summary_rows_tl
      {
        \par\nobreak
        \noindent\dotfill\par
        \nobreak
        \section*{Zebra~Notes}
        \par \medskip
        \begin{center}
          \begin{tabular}{lr}
            \hline
            \textbf{Type} & \textbf{Number} \\\hline
            \tl_use:N \l@@_summary_rows_tl
            \hline
            \textbf{Total} & \textbf{\int_use:N \l@@_total_notes_int} \\
            \hline
          \end{tabular}
        \end{center}
        \if@twocolumn
          \clearpage
          \onecolumn
        \else
          \par \medskip
        \fi
        \begingroup
          \small
          \noindent{\bfseries List~of~notes}\par
          \seq_map_inline:Nn \g@@_note_types_seq
            { \@@_print_note_group:n {##1} }
        \endgroup
      }
  }
%    \end{macrocode}
%
% \begin{macro}{\zebranewnote}
% All note types are created with \cs{zebranewnote}.
% \changes{v0.8.0}{2019/07/04}{Fix on \cs{global} for examples}
%    \begin{macrocode}
\cs_new_protected:Npn \zebranewnote #1#2
  { \@@_new_note_type:nn {#1} {#2} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\todo}
% \begin{macro}{\note}
% \begin{macro}{\fixed}
% \begin{macro}{\comment}
% \begin{macro}{\placeholder}
% They are defined with \cs{zebranewnote}. The colors are picked up from the default
% ones from \pkg{xcolor}.
%    \begin{macrocode}
\zebranewnote{todo}{purple}
\zebranewnote{fixed}{teal}
\zebranewnote{comment}{blue}
\zebranewnote{note}{violet}
\zebranewnote{placeholder}{gray}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%\subsection{Print summary at end of the document}
%
% A summary table and a detailed grouped note list are inserted automatically at the
% end of the document. Each note type with at least one instance is listed with
% its colour and count, followed by notes grouped by type.
%
%    \begin{macrocode}
\hook_gput_code:nnn { enddocument } { zebra-goodies }
  {
    \bool_if:NT \l@@_draft_bool
      {
        \bool_if:NT \l@@_listofnotes_bool
          { \@@_print_notes: }
      }
  }
\ExplSyntaxOff
%    \end{macrocode}
%
%\subsection{Personal Colors}
%\label{sec:colors}
% Several colors are defined for plots.
%    \begin{macrocode}
\definecolor{zebrablue}{HTML}{4F81BD}
\definecolor{zebrared}{HTML}{C0504D}
\definecolor{zebragreen}{HTML}{9BBB00}
\definecolor{zebrapurple}{HTML}{9F4C7C}
\definecolor{zebrayellow}{HTML}{D9CD2E}
\definecolor{zebragreen2}{HTML}{00E000}
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%\subsection{Two-column demo}
%
% A standalone two-column document used to generate the demo figure
% included in the documentation. It is extracted automatically by
% docstrip and compiled during the build.
%    \begin{macrocode}
%<*demo-twocol>
\documentclass[twocolumn,a4paper]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{zebra-goodies}
\usepackage{lipsum}
\pagestyle{empty}
\begin{document}
\section{Demo name\comment{revise the name}}
\lipsum[1] \todo[alice]{revise the introduction}

\lipsum[2] \note[bob]{add a reference here}
\lipsum[3] \fixed[carol]{looks good now}
\lipsum[4] \todo[dave]{needs more data}

\lipsum[5] \placeholder[eve]{insert figure}

\lipsum[6] \note[frank]{check the numbers}

\lipsum[7] \comment[tom]{is it you, jerry?}

\lipsum[8] \fixed[heidi]{typo corrected}

You can place \todo[judy]{summarise the findings} anywhere.
\lipsum[9][10-11]
\end{document}
%</demo-twocol>
%    \end{macrocode}
%
%\end{implementation}
%
%\PrintChanges
%\PrintIndex
