diff options
author | Karl Berry <karl@freefriends.org> | 2023-01-31 20:51:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-01-31 20:51:08 +0000 |
commit | 4a58a56ff46330f5f6d5cac244d11661aa9fce65 (patch) | |
tree | 0273c998eb681d80ba0caa2522de76ad23fbb497 /Master/texmf-dist/source/latex/todonotes/todonotes.dtx | |
parent | c547d9ca0c103a5d52013a410ab9bf8fcea779a0 (diff) |
todonotes (31jan23)
git-svn-id: svn://tug.org/texlive/trunk@65699 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/todonotes/todonotes.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/todonotes/todonotes.dtx | 142 |
1 files changed, 126 insertions, 16 deletions
diff --git a/Master/texmf-dist/source/latex/todonotes/todonotes.dtx b/Master/texmf-dist/source/latex/todonotes/todonotes.dtx index 9bea77d9250..d9ddd09a354 100644 --- a/Master/texmf-dist/source/latex/todonotes/todonotes.dtx +++ b/Master/texmf-dist/source/latex/todonotes/todonotes.dtx @@ -20,14 +20,14 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{todonotes} %<*package> - [2021/06/04 v1.1.5 Todonotes source and documentation.] + [2023/01/31 v1.1.6 Todonotes source and documentation.] %</package> % %<*driver> \documentclass{ltxdoc} \usepackage{wrapfig} \usepackage[colorlinks, linkcolor=black, urlcolor=blue]{hyperref} -\usepackage[colorinlistoftodos, loadshadowlibrary]{todonotes}[2021/06/04] +\usepackage[colorinlistoftodos, loadshadowlibrary]{todonotes}[2023/01/31] \usepackage{amsmath} \usepackage{setspace} \usepackage{soul} @@ -45,7 +45,7 @@ %</driver> % \fi % -% \CheckSum{734} +% \CheckSum{760} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -213,6 +213,9 @@ % shadows. Actually use the tickmarkheight option as suggested by % José Francisco Loff library by default. Described a workaround for using % the standalone document class.} +% \changes{1.1.6}{2023/01/31}{Fix issue 64 by adding the command definetodostyle and +% the format option to the todo and missingfigure commands. +% Pull request by rzach.} % \GetFileInfo{todonotes.dtx} % % \DoNotIndex{\newcommand,\newenvironment} @@ -241,11 +244,14 @@ % \newpage % \section{Introduction} % -% The |todonotes| package makes three commands available to the +% The |todonotes| package makes four commands available to the % user: |\todo[]{}|, |\missingfigure{}| and |\listoftodos|. % |\todo[]{}| and |\missingfigure{}| makes it possible to insert % notes in your document about things that has to be done later -% (todonotes \ldots). +% (todonotes \ldots). +% The |\todostyle| command allows the user to +% define named custom styles as abbreviations for lists of other +% options that can be given to the |\todo| command. % I developed the basic functionality of the package while I worked % on my bachelor project. % @@ -315,6 +321,19 @@ % list of todos. The command should be placed right before the % |\listoftodos| command. % +% \DescribeMacro{\todostyle\marg{name}\marg{style}} +% The |\todostyle| command defines a new optional argument to the +% |\todo| command \meta{name} which sets the options given by +% \meta{style}. For instance, after issuing +% \begin{verbatim} +% \todostyle{red}{color=red,shadow}\end{verbatim} +% the command |\todonote[red]{Stuff}| has the same effect as: +% \begin{verbatim} +% \todonote[color=red,shadow]{Stuff}\end{verbatim} +% Defined styles should be used +% as the first optional argument to |\todo|, as they reset all +% predefined options to their defaults. +% % \subsection{Package options} % \label{subsecPackageOptions} % \DescribeMacro{disable} @@ -385,8 +404,9 @@ % % \DescribeMacro{textwidth} % |textwidth=length| sets the width of a todo item in the margin to -% |length|. The width of inline todonotes will allways be the same -% as the current line width. +% |length|. The width of inline todonotes defaults to the width of the +% current |\linewidth| but can be adjusted using the +% |inlinewidth| option. % % \DescribeMacro{textsize} % |textsize=value| sets the default text size of the inserted @@ -794,6 +814,11 @@ % % \subsubsection{Todonotes in footnotes} % Placing todonotes in footnotes throws a lot of errors. +% However inline notes seems to work fine, as shown here +% \footnote{Note \todo[inline]{description}}: +% \begin{verbatim} +% \footnote{Note \todo[inline]{description}} +% \end{verbatim} % Richard Stanton comes with the following work around. % \begin{verbatim} % \renewcommand{\marginpar}{\marginnote} @@ -857,7 +882,17 @@ % \end{document} % \end{verbatim} % +% \subsubsection{Issues with user-defined styles} +% +% Using an option defined using |\todostyle| will reset all predefined +% options to their defaults. For instance, +% |\todo[inline,newstyle]{Stuff}| will not be inline; however +% |\todo[newstyle,inline]{Stuff}| will be. % +% |\todostyle| does not check if the name of the defined style is +% already one of the defined options, so, e.g., +% |\todostyle{inline}{color=red}| will redefine the |inline| option +% to produce red marginal notes. % % \subsection{Things to improve} % This is a list of things I consider to improve sometime in the @@ -937,6 +972,15 @@ % This \todoredefined[color=green]{Test of newly defined command, requesting a green color.} % can be done with all the accepted options for the |\todo| command. % +% If only available options to the |\todo| command are desired in the +% defined command, a similar effect can be achieved by defining a new style. +% For instance, +% \begin{verbatim} +% \todostyle{red}{color=red} +% \todo[red,inline]{A red to do}\end{verbatim} +% \todostyle{red}{color=red}% +% will produce a note like this:\todo[red,inline]{A todo with user-defined +% style \emph{red}} % % % \subsubsection{Enumerate todonotes} @@ -1296,6 +1340,38 @@ % \tododone[disable]{Testing} % % +% \subsubsection{Notes in both left and right margin} +% +% If you want to add many todonotes in your document, it can be beneficial to +% use both the left and right margins for the inserted notes. +% This can be achieved by defining a helper function the following way. +% The main drawback is that notes inserted using the \verb!marginnote! +% command does not float and thus they can get to overlap. +% This idea was suggested by +% \href{https://github.com/henrikmidtiby/todonotes/issues/56}{FranzAtGithub}. +% +% \begin{verbatim} +% \usepackage{marginnote} +% \usepackage{etoolbox} +% +% \newtoggle{lmargin} +% \newcommand{\alternatingtodo}[2][]{% +% \iftoggle{lmargin}% +% {% +% \todo[#1]{#2} +% \togglefalse{lmargin} +% }{% +% {% +% \let\marginpar\marginnote% +% \reversemarginpar% +% \todo[#1]{#2}% +% }% +% \toggletrue{lmargin}% +% }% +% }% +% \end{verbatim} +% +% % % \iffalse % \StopEventually{\PrintChanges\PrintIndex} @@ -1307,7 +1383,7 @@ % % Identifies the package and loads the packages dependences. % \begin{macrocode} -\ProvidesPackage{todonotes}[2021/06/04] +\ProvidesPackage{todonotes}[2023/01/31] \RequirePackage{ifthen} \RequirePackage{xkeyval} \RequirePackage{xcolor} @@ -1533,6 +1609,17 @@ prior to loading the todonotes package.} \else\fi% \define@key{todonotes.sty}% {textwidth}{\renewcommand{\@todonotes@textwidth}{#1}} % \end{macrocode} +% Make the formatting of a note an option. +% Notes are formatted using |\todoformat|, which by default does +% nothing. +% If the option |format=cmd| is given, notes are formatted using +% |\cmd| instead. +% Default formatting can also be changed by redefining |\todoformat|. +% \begin{macrocode} +\newcommand{\todoformat}[1]{#1} +\define@key{todonotes.sty}% + {format}{\renewcommand{\todoformat}{\@nameuse{#1}}} +% \end{macrocode} % Make the text size as an option, accept both |size| and |textsize|. % \begin{macrocode} \define@key{todonotes.sty}% @@ -1625,6 +1712,14 @@ prior to loading the todonotes package.} \else\fi% \define@key{todonotes}{tickmarkheight}{% \renewcommand{\@todonotes@tickmarkheight}{#1}}% % \end{macrocode} +% Make formatting of notes a per-note option as well, by redefining +% the internal |\@todonotes@format| command, which is then used in +% formatting the actual note. +% \begin{macrocode} +\newcommand{\@todonotes@format}{\todoformat}% +\define@key{todonotes}{format}{% + \renewcommand{\@todonotes@format}{\@nameuse{#1}}}% +% \end{macrocode} % Set a relative font size % \begin{macrocode} \newcommand{\@todonotes@sizecommand}{}% @@ -1720,6 +1815,7 @@ prior to loading the todonotes package.} \else\fi% backgroundcolor=\@todonotes@backgroundcolor,% textcolor=\@todonotes@textcolor,% bordercolor=\@todonotes@bordercolor,% + format=todoformat,% tickmarkheight=\@todonotes@defaulttickmarkheight,% nofancyline,% nodisable,% @@ -1931,9 +2027,10 @@ prior to loading the todonotes package.} \else\fi% \end{tikzpicture}% \if@todonotes@inlinepar\par\fi}% \if@todonotes@authorgiven% - {\noindent \@todonotes@useSizeCommand \@todonotes@author:\,\@todonotes@text}% + {\noindent \@todonotes@useSizeCommand \@todonotes@author:\,\@todonotes@format{\@todonotes@text}}% \else% - {\noindent \@todonotes@useSizeCommand \@todonotes@text}% + {\noindent \@todonotes@useSizeCommand% + \@todonotes@format{\@todonotes@text}}% \fi {\if@todonotes@inlinepar\par\noindent\fi% \begin{tikzpicture}[remember picture]% @@ -1945,9 +2042,10 @@ prior to loading the todonotes package.} \else\fi% \begin{tikzpicture}[remember picture]% \draw node[inlinenotestyle,font=\@todonotes@useSizeCommand]{% \if@todonotes@authorgiven% - {\noindent \@todonotes@author:\,\@todonotes@text}% + {\noindent \@todonotes@author:\,% + \@todonotes@format{\@todonotes@text}}% \else% - {\noindent \@todonotes@text}% + {\noindent \@todonotes@format{\@todonotes@text}}% \fi};% \end{tikzpicture}% \if@todonotes@inlinepar\par\fi}% @@ -1964,9 +2062,10 @@ prior to loading the todonotes package.} \else\fi% \end{tikzpicture}\\% \begin{minipage}{\@todonotes@textwidth}% \if@todonotes@authorgiven% - \@todonotes@useSizeCommand \@todonotes@author \@todonotes@text% + \@todonotes@useSizeCommand \@todonotes@author:\, + \@todonotes@format{\@todonotes@text}% \else% - \@todonotes@useSizeCommand \@todonotes@text% + \@todonotes@useSizeCommand\@todonotes@format{\@todonotes@text}% \fi% \end{minipage}\\% \begin{tikzpicture}[remember picture]% @@ -1982,10 +2081,10 @@ prior to loading the todonotes package.} \else\fi% {\@todonotes@author};% \node(Y)[below=of X]{};% \draw node[notestyle,font=\@todonotes@useSizeCommand,anchor=north] (inNote) at (X.south)% - {\@todonotes@text};% + {\@todonotes@format{\@todonotes@text}};% \else% \draw node[notestyle,font=\@todonotes@useSizeCommand,anchor=north] (inNote) at (X.north)% - {\@todonotes@text};% + {\@todonotes@format{\@todonotes@text}};% \fi% \end{tikzpicture}% \hbadness \originalHbadness% @@ -2111,6 +2210,17 @@ prior to loading the todonotes package.} \else\fi% \newif\if@todonotes@vmode % \end{macrocode} % \end{macro} +% \begin{macro}{\todostyle} +% Define the |\todostyle| macro. |\todostyle|\marg{name}\marg{style} +% defines an |xkeyval| option \meta{name} that, when called in a +% |\todo| or |\missingfigure| command, sets the preset options +% followed by \meta{style}. +% \begin{macrocode} +\newcommand*{\todostyle}[2]{% + \define@key{todonotes}{#1}[]{% + \setkeys{todonotes}{#2}}} +% \end{macrocode} +% \end{macro} % \appendix % \newpage % \Finale |