From 229b52726ac1d3f0dbaae45cf5b9a79af1ce0df1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 28 May 2012 22:23:11 +0000 Subject: fnpct (28may12) git-svn-id: svn://tug.org/texlive/trunk@26695 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/fnpct/README | 4 +- Master/texmf-dist/doc/latex/fnpct/fnpct_en.pdf | Bin 844715 -> 851328 bytes Master/texmf-dist/doc/latex/fnpct/fnpct_en.tex | 166 +++++++++----- Master/texmf-dist/tex/latex/fnpct/fnpct.sty | 305 +++++++++++++++++-------- 4 files changed, 330 insertions(+), 145 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/fnpct/README b/Master/texmf-dist/doc/latex/fnpct/README index 18fdd3e81fb..b157277e92c 100644 --- a/Master/texmf-dist/doc/latex/fnpct/README +++ b/Master/texmf-dist/doc/latex/fnpct/README @@ -1,9 +1,9 @@ -------------------------------------------------------------------------- -the FNPCT package v0.1a +the FNPCT package v0.2 footnote kerning -2012/05/23 +2012/05/26 -------------------------------------------------------------------------- Clemens Niederberger Web: https://bitbucket.org/cgnieder/fnpct/ diff --git a/Master/texmf-dist/doc/latex/fnpct/fnpct_en.pdf b/Master/texmf-dist/doc/latex/fnpct/fnpct_en.pdf index 57f046e64a0..8d0decec422 100644 Binary files a/Master/texmf-dist/doc/latex/fnpct/fnpct_en.pdf and b/Master/texmf-dist/doc/latex/fnpct/fnpct_en.pdf differ diff --git a/Master/texmf-dist/doc/latex/fnpct/fnpct_en.tex b/Master/texmf-dist/doc/latex/fnpct/fnpct_en.tex index 000f7269181..2a5dc365c38 100644 --- a/Master/texmf-dist/doc/latex/fnpct/fnpct_en.tex +++ b/Master/texmf-dist/doc/latex/fnpct/fnpct_en.tex @@ -3,7 +3,7 @@ % % footnote kerning % -% 2012/05/22 +% 2012/05/25 % -------------------------------------------------------------------------- % Clemens Niederberger % Web: https://bitbucket.org/cgnieder/fnpct/ @@ -68,7 +68,7 @@ thempfootnote, writeinnernotes } -\setfnpct{multiple} +\setfnpct{multiple,add-punct-marks=:[0pt][-.05em]} \usepackage{endnotes} \usepackage{parnotes} @@ -197,11 +197,14 @@ suffix_3p "\\nohyperpage{\\,ff.}" \end{filecontents} -\newcommand\setapart[1]{\medskip\hspace{1em}#1\medskip} +\newcommand\setapart[1]{% + \begin{quote} + #1 + \end{quote}} \let\verb\lstinline \TitlePicture{\parbox{.75\textwidth}{The \fnpct package basically does two things -to footnotes: if footnote marks are followed by a comma or a full stop the order +to footnotes: if footnote marks are followed by a punctuation mark the order of footnote and punctuation mark is reversed and the kerning gets adjusted. As a side effect a new method of creating multiple footnotes and some other features are provided.}} @@ -212,15 +215,16 @@ provided.}} \section{License and Requirements} \fnpct is placed under the terms of the LaTeX Project Public License, version 1.3 or later (\url{http://www.latex-project.org/lppl.txt}). -It has the status \enquote{maintained}. +It has the status ``maintained.'' -\fnpct depends on the \paket{l3kernel} and \paket*{xparse} which is part of the -\paket{l3packages} bundle. +\fnpct depends on the \paket*{l3kernel}, \paket*{xparse}, \paket*{l3keys2e} and +\paket*{scrlfile}. \section{What's it all about?} \subsection{Basics}\secidx{basics} The \fnpct package basically does two things to footnotes: if footnote marks are -followed by a comma or a full stop the order of footnote and punctuation mark is +followed by a comma or a full stop\footnote{More punctuation marks can be added +through a package option.} the order of footnote and punctuation mark is reversed and the kerning gets adjusted. As a side effect a new method of creating multiple footnotes\footnote{like;this} is provided, see section \ref{sec:multiple} for details. @@ -237,7 +241,7 @@ the amount specified by the option \key{before-footnote-space} (see section All examples in this documentation use -\setapart{\cmd{renewcommand}\cmd{thempfootnote}{\cmd{arabic}{mpfootnote}}}. +\setapart{\cmd{renewcommand}\cmd{thempfootnote}{\cmd{arabic}{mpfootnote}}.} Now, let's see some action: \begin{beispiel} @@ -250,13 +254,29 @@ Now, let's see some action: \end{beispiel} To ensure that the kerning is set the right way the footnote \emph{must} be placed -\emph{before} the dot or the comma. \emph{The command can look ahead but not look back}. -This means if you place the \cmd{footnote} command after a dot or a comma it is -treated as if following a word, \ie a thin space is inserted: effectivly the opposite +\emph{before} the full stop or the comma. \emph{The command can look ahead but not look back}. +This means if you place the \cmd{footnote} command after a full stop or a comma it is +treated as if following a word, \ie a thin space is inserted: effectively the opposite of the desired behaviour. The order-switching can be prevented using a package option since not all countries -and languages have the same typographic conventions. +and languages have the same typographic conventions. In this case the full stop +and the comma are move a bit back. + +\bigskip\hfil +\begin{minipage}{.25\linewidth} +\setlength\parindent{0pt}% +without \fnpct:\\ +{\setfnpct{dont-mess-around}% +\null\quad text.\footnotemark[1]\\ +\null\quad text\footnotemark[1]}. + +with \fnpct:\\ +\null\quad text\footnotemark[1].\\ +\setfnpct{punct-after}% +\null\quad text\footnotemark[1]. +\end{minipage}\hfil + \begin{beschreibung} \option{punct-after}{\default{true}/false} when \code{true} the punctuation sign will be placed \emph{after} the footnote. @@ -281,12 +301,15 @@ Like all options it can also be set using the setup command. One maybe want to put some footnote marks \emph{before} the punctuation and some after, for example because the first one describes a single word but the second one a whole sentence. For this purpose \fnpct adds a \code{*} argument to \cmd{footnote} -and \cmd{footnotemark}: +and \cmd{footnotemark}. The complete new syntax now is as follows: \begin{beschreibung} - \befehl[footnotea]{footnote}*[]{} new \code{*} argument added. - \befehl[footnotemarka]{footnotemark}*[] new \code{*} argument added. + \Befehl{footnote}*[]{}\code{} \cnpkgdocarrow\ new + \code{*} argument added. \code{} is the optional trailing punctuation + mark. + \Befehl{footnotemark}*[]\code{} \cnpkgdocarrow\ new \code{*} argument + added. \code{} is the optional trailing punctuation mark. \end{beschreibung} -This argument temporarily turns off the punctuation/footnote switching. +The \code{*} argument temporarily turns off the punctuation/footnote switching. \begin{beispiel} \begin{minipage}{.4\linewidth} \noindent The three little pigs built their houses @@ -300,24 +323,38 @@ This argument temporarily turns off the punctuation/footnote switching. \section{Options}\secidx{options}\label{sec:options} Most package options are listed below. They all can be set as a package option or with the \cmd{setfnpct} command. Most of them are for adjusting the kerning. + +\default{Underlined} values are set if the option is used without value. \begin{beschreibung} - \option{after-dot-space}{} space to be inserted after a dot and before the - footnote mark. Default = \code{-.06em} - \option{after-comma-space}{} space to be inserted after a comma and before - the footnote mark. Default = \code{-.06em} - \option{after-punct-space}{} set both spaces. + \option{add-punct-marks}{[][]} add another punctuation + mark for the position switching and spacify kerning if necessary. An existing entry + will be overwritten. This option accepts list of marks. + \option{remove-punct-marks}{} remove punctuation mark from the kerning/position + switching behaviour. This option accepts a list of marks. + \option{after-dot-space}{} space to be inserted after a footnote mark and + before the full stop (``footnote \emph{after} dot''). A negative space + will move the full stop further to the footnote mark. Default = \code{-.06em} + \option{after-comma-space}{} space to be inserted after a footnote mark and + before the comma (``footnote \emph{after} comma''). A negative space + will move the comma further to the footnote mark. Default = \code{-.06em} + \option{after-punct-space}{} set \emph{all} spaces, \ie also the ones for + marks you've added with \key{add-punct-marks}. \option{punct-after}{\default{true}/false} when \code{true} the punctuation sign will be placed \emph{after} the footnote. - \option{before-dot-space}{} space to be inserted before a dot and after the - footnote mark, \ie with \key{punct-after}{true}. Default = \code{-.15em} - \option{before-comma-space}{} space to be inserted before a comma and after - the footnote mark, \ie with \key{punct-after}{true}. Default = \code{-.15em} - \option{before-punct-space}{} set both spaces. - \option{before-footnote-space}{} space to be inserted between a word and the - following footnote mark. Default = \code{.06em} - \option{dont-mess-around} sets all mentioned lengths to \code{0} and \key{punct-after}{true}. - Basically this is as if you hadn't loaded \fnpct except the multiple footnote - command is still available, see section \ref{sec:multiple}. + \option{before-dot-space}{} space to be inserted after a footnote mark and + before the full stop (``footnote \emph{before} dot''), \ie with + \key{punct-after}{true}. Default = \code{-.15em} + \option{before-comma-space}{} space to be inserted after a footnote mark and + before the comma (``footnote \emph{before} comma''), \ie with + \key{punct-after}{true}. Default = \code{-.15em} + \option{before-punct-space}{} set \emph{all} spaces, \ie also the ones for + marks you've added with \key{add-punct-marks}. + \option{before-footnote-space}{} space to be inserted between a word and + the following footnote mark. Default = \code{.06em} + \option{dont-mess-around} sets all mentioned lengths to \code{0pt} and + \key{punct-after}{true}. Basically this is as if you hadn't loaded \fnpct except + the multiple footnote commands and \cmd{innernote} are still available, see + sections \ref{sec:multiple} and \ref{sec:nested}, respectively. \option{multiple}{\default{true}/false} lets \cmd{footnote} be equal to \cmd{multfootnote} \option{mult-fn-delim}{} sets the delimiter for the \cmd{multfootnote} @@ -331,6 +368,29 @@ with the \cmd{setfnpct} command. Most of them are for adjusting the kerning. = \code{false} \end{beschreibung} +So if you want to extend the punctuation switching and kerning to other punctuation +marks you can do something like this: +\begin{beispiel} + \setfnpct{add-punct-marks=!?} + \begin{minipage}{.4\linewidth} + \noindent The three little pigs built their houses + out of straw\footnote{not to be confused with hay}? + Sticks\footnote{or lumber according to some sources} + and bricks\footnote{probably fired clay bricks}! + \end{minipage} +\end{beispiel} + +Or with some additional spacing: +\begin{beispiel} + \setfnpct{add-punct-marks=![.03em]?[.03em]} + \begin{minipage}{.4\linewidth} + \noindent The three little pigs built their houses + out of straw\footnote{not to be confused with hay}? + Sticks\footnote{or lumber according to some sources} + and bricks\footnote{probably fired clay bricks}! + \end{minipage} +\end{beispiel} + Let's take a look at an example with some ridiculous settings: \begin{beispiel} % some ridiculous settings: @@ -372,9 +432,9 @@ Some of the options are explained in a bit more detail in the next sections. Since multiple footnotes have to be treated differently\footnote{see these footnotes;for an example}, \fnpct provides an extra command for that: \begin{beschreibung} - \befehl{multfootnote}*{;;} different footnotes are separated - with a semicolon. The \code{*} turns the footnote/punctuation switching temporarily - off. + \Befehl{multfootnote}*{;;}\code{} \cnpkgdocarrow\ + different footnotes are separated with a semicolon. The \code{*} turns the + footnote/punctuation switching temporarily off. \end{beschreibung} \begin{beispiel} \begin{minipage}{.4\linewidth} @@ -386,8 +446,11 @@ Since multiple footnotes have to be treated differently\footnote{see these footn \end{minipage} \end{beispiel} -Every of the items of the list has an optional argument equivalent to the optional -argument of \cmd{footnote}: +Every of the items of the list has an optional \code{*} argument and an optional +argument equivalent to the optional argument of \cmd{footnotetext}: +\begin{beschreibung} + \Befehl{multfootnote}{*[];...} +\end{beschreibung} \begin{beispiel} \begin{minipage}{.4\linewidth} \noindent The three little pigs built their houses @@ -410,7 +473,7 @@ without disrupting the multiple setting. The following example is shown in figur margin=5pt, bottom=1.5cm]{geometry} -\usepackage[multiple]{fnpct} +\usepackage{fnpct} \begin{document} \noindent The three little pigs built their houses @@ -427,10 +490,10 @@ without disrupting the multiple setting. The following example is shown in figur \caption{nested footnotes}\label{fig:nested:mult} \end{figure} - +\newpage \subsection{The delimiter and separator}\secidx[delimiter]{multiple footnotes}\secidx[separator]{multiple footnotes} Since the semicolon might be part of the footnote text you might have some trouble. -But there are ways around. Maybe try enclosing it with braces: +But there are ways around. Maybe try enclosing it in braces: \begin{beispiel} \begin{minipage}{.4\linewidth} \noindent The three little pigs built their houses @@ -441,7 +504,7 @@ But there are ways around. Maybe try enclosing it with braces: \end{minipage} \end{beispiel} -There are options which lets you choose the (input) delimiter and the (output) +There also are options which lets you choose the (input) delimiter and the (output) separator: \begin{beschreibung} \option{mult-fn-delim}{} choose delimiter for the \cmd{multfootnote}. @@ -488,12 +551,12 @@ If you want you can turn all footnotes into \cmd{multfootnote}s. \end{beispiel} \secidx*{multiple footnotes} -\section{Nested Footnotes}\secidx{nested footnotes} +\section{Nested Footnotes}\secidx{nested footnotes}\label{sec:nested} \fnpct provides some support for nested footnotes. There are some restrictions, though. The command below can be used inside \cmd{footnote} and \cmd{multfootnote}, but not inside another \cmd{innernote}: \begin{beschreibung} - \befehl{innernote}*[]{} a nested footnote. + \Befehl{innernote}*[]{}\code{} \cnpkgdocarrow\ a nested footnote. \end{beschreibung} The inner node uses a \cmd{footnotemark} internally and the mark will be set with the definition it has at begin document. @@ -707,7 +770,8 @@ The \paket{endnotes} \cite{endnotes} package povides the commands \cmd{endnote} and \cmd{endnotemark} which can be used to output all notes at the end of a chapter, say. -If the package is loaded both commands are adapted: +If the package is loaded both commands are adapted\footnote*{see section \ref{sec:adapt} +on manual adaption}: \begin{beispiel}[code only] % `fnpct' does this for you: \AdaptNote\endnote\multendnote @@ -748,8 +812,8 @@ repeat the footnote text on the same page in the bottom. The document needs several runs to get all the numbers and footnotes right. Every fixed footnote declared with \cmd{DeclareFixedFootnote} gets an optional -\code{*} to prevent the punctuation switching. There is \emph{no} mult-variant -of the fixed notes! +\code{*} to prevent the punctuation switching. \emph{There is \emph{no} mult-variant +of the fixed notes!} Since this document cannot easily combine \emph{every} footnote package at the same time for demonstration purposes the following code is shown in figure \ref{fig:fixfoot}: @@ -799,8 +863,8 @@ escaping mechanism through \cmd{makesavenoteenv}. \subsection{manyfoot}\secidx[manyfoot]{other packages} The \paket{manyfoot} package \cite{manyfoot} is not and will not directly be supported. It is loaded by \paket{bigfoot} (see section \ref{ssec:bigfoot}), anyway. -And since the latter states this in its documentation -\begin{zitat}[David Kastrup \cite{bigfoot}] +And since the latter states in its documentation +\begin{zitat}[David Kastrup \textup{\cite{bigfoot}}] Purpose of this package is to provide a one-stop solution to almost all problems related to footnotes. You can use it as a drop-in replacement of the `\paket{manyfoot}' package, but without many of its shortcomings, and quite a few features of its @@ -890,7 +954,7 @@ of the \paket{yafoot} \cite{yafoot} bundle. Just for reference: these packages a \paket*{pfnote}, \paket*{fnpos} and \paket*{dblfnote}. \secidx*{other packages} -\section{Adapting note commands}\secidx{adapting notes} +\section{Adapting note commands}\secidx{adapting notes}\label{sec:adapt} If a package is not natively supported you can try and adapt commands yourself. You'll need to use one of the following commands. Please be aware that if the adapted command does not match the required syntax it will get the required syntax @@ -946,8 +1010,8 @@ text in a sidenote.;A second sidenote.}. \subsection{Adapting \code{\textbackslash\textcolor{code}{footcite}} and siblings} \secidx[biblatex]{adapting notes}\label{ssec:adapt:footcite} -If you're willing to sacrifice \cmd{footcite}'s \code{*} argument which it has -in some styles you can adapt the commands provided by \paket{biblatex} as well: +If you're willing to sacrifice \cmd{footcite}'s \code{*} argument (which it has +in some styles) you can adapt the commands provided by \paket{biblatex} as well: \begin{beispiel} % used in preamble: \AdaptNoteOpt\footcite\multfootcite diff --git a/Master/texmf-dist/tex/latex/fnpct/fnpct.sty b/Master/texmf-dist/tex/latex/fnpct/fnpct.sty index f3d3eb7c1c2..69c64889915 100644 --- a/Master/texmf-dist/tex/latex/fnpct/fnpct.sty +++ b/Master/texmf-dist/tex/latex/fnpct/fnpct.sty @@ -3,7 +3,7 @@ % % footnote kerning % -% 2012/05/23 +% 2012/05/26 % -------------------------------------------------------------------------- % Clemens Niederberger % Web: https://bitbucket.org/cgnieder/fnpct/ @@ -32,8 +32,8 @@ \RequirePackage { xparse , l3keys2e , scrlfile } \ProvidesExplPackage {fnpct} - {2012/05/23} - {0.1a} + {2012/05/26} + {0.2} {footnote kerning} % -------------------------------------------------------------------------- @@ -104,6 +104,90 @@ \bool_new:N \l_fnpct_bigfoot_default_top_bool \bool_new:N \l_fnpct_normal_marks_bool +% default punctuation marks for switching: +\tl_new:N \l_fnpct_punctuation_marks_tl +\tl_set:Nn \l_fnpct_punctuation_marks_tl { ., } +\prop_new:N \l_fnpct_punctuation_marks_after_prop +\prop_new:N \l_fnpct_punctuation_marks_before_prop +\prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { . } { \l_fnpct_after_dot_dim } +\prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { , } { \l_fnpct_after_comma_dim } +\prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { . } { \l_fnpct_before_dot_dim } +\prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { , } { \l_fnpct_before_comma_dim } + +\cs_new:Npn \fnpct_rm_punctuation:n #1 + { + \tl_remove_all:Nn \l_fnpct_punctuation_marks_tl { #1 } + \prop_del:Nn \l_fnpct_punctuation_marks_after_prop { #1 } + \prop_del:Nn \l_fnpct_punctuation_marks_before_prop { #1 } + } + +\tl_new:N \l_fnpct_last_punct_mark_tl + +\cs_new:Npn \fnpct_add_punctuation:n #1 + { \fnpct_add_punctuation_aux:w #1 [ \q_no_value ] \q_no_value \q_stop } +\cs_generate_variant:Nn \fnpct_add_punctuation:n { V } + +\cs_new:Npn \fnpct_add_punctuation_aux:w #1[#2]#3 \q_stop + { + \quark_if_no_value:nTF { #2 } + { + % there is no option at all + \tl_map_inline:nn { #1 } + { + \tl_put_right:Nn \l_fnpct_punctuation_marks_tl { ##1 } + \prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { ##1 } { 0pt } + \prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { ##1 } { 0pt } + \tl_set:Nx \l_fnpct_last_punct_mark_tl { ##1 } + } + } + { + \tl_if_blank:nTF { #1 } + { + % #2 is a second option (= before space) + \prop_put:NVn \l_fnpct_punctuation_marks_before_prop + \l_fnpct_last_punct_mark_tl { #2 } + } + { + % #2 is a first option (= after space), #1 might be more than one token: + \tl_if_single_token:nTF { #1 } + { + \tl_put_right:Nn \l_fnpct_punctuation_marks_tl { #1 } + \prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { #1 } { #2 } + \prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { #1 } { 0pt } + \tl_set:Nx \l_fnpct_last_punct_mark_tl { #1 } + } + { + \int_zero:N \l_tmpa_int + \tl_map_inline:nn { #1 } + { + \tl_put_right:Nn \l_fnpct_punctuation_marks_tl { ##1 } + \int_compare:nTF { \l_tmpa_int < ( \tl_length:n { #1 } - 1 ) } + { + \prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { ##1 } { 0pt } + \prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { ##1 } { 0pt } + } + { + \prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { ##1 } { #2 } + \prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { ##1 } { 0pt } + } + \tl_set:Nx \l_fnpct_last_punct_mark_tl { ##1 } + \int_incr:N \l_tmpa_int + } + } + } + } + % is there more? + \tl_if_eq:nnF { #3 } { [\q_no_value]\q_no_value } + { + \quark_if_no_value:nF { #3 } + { + \tl_set:Nn \l_tmpa_tl { #3 } + \tl_remove_all:Nn \l_tmpa_tl { [\q_no_value]\q_no_value } + \fnpct_add_punctuation:V \l_tmpa_tl + } + } + } + % options: \keys_define:nn { fnpct } { @@ -114,19 +198,19 @@ before-comma-space .dim_set:N = \l_fnpct_before_comma_dim , before-dot-space .dim_set:N = \l_fnpct_before_dot_dim , after-punct-space .code:n = - \dim_set:Nn \l_fnpct_after_comma_dim { #1 } - \dim_set:Nn \l_fnpct_after_dot_dim { #1 } , + \prop_map_inline:Nn \l_fnpct_punctuation_marks_after_prop + { \prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { ##1 } { #1 } } , before-punct-space .code:n = - \dim_set:Nn \l_fnpct_before_comma_dim { #1 } - \dim_set:Nn \l_fnpct_before_dot_dim { #1 } , + \prop_map_inline:Nn \l_fnpct_punctuation_marks_before_prop + { \prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { ##1 } { #1 } } , before-footnote-space .dim_set:N = \l_fnpct_before_footnote_dim , punct-after .bool_set:N = \l_fnpct_punct_after_bool , punct-after .default:n = true , dont-mess-around .code:n = - \dim_zero:N \l_fnpct_after_comma_dim - \dim_zero:N \l_fnpct_after_dot_dim - \dim_zero:N \l_fnpct_before_comma_dim - \dim_zero:N \l_fnpct_before_dot_dim + \prop_map_inline:Nn \l_fnpct_punctuation_marks_after_prop + { \prop_put:Nnn \l_fnpct_punctuation_marks_after_prop { ##1 } { 0pt } } + \prop_map_inline:Nn \l_fnpct_punctuation_marks_before_prop + { \prop_put:Nnn \l_fnpct_punctuation_marks_before_prop { ##1 } { 0pt } } \dim_zero:N \l_fnpct_before_footnote_dim \bool_set_true:N \l_fnpct_punct_after_bool \fnpct_dont_mess_around: , @@ -141,13 +225,17 @@ normal-mark-width .dim_set:N = \l_fnpct_normal_mark_width_dim , normal-indent .dim_set:N = \l_fnpct_normal_indent_dim , normal-parindent .dim_set:N = \l_fnpct_normal_parindent_dim , - verb-format .tl_set:N = \l_fnpct_verbatim_format_tl + verb-format .tl_set:N = \l_fnpct_verbatim_format_tl , + add-punct-marks .code:n = \fnpct_add_punctuation:n { #1 } , + remove-punct-marks .code:n = + \tl_map_function:nN { #1 } \fnpct_rm_punctuation:n } \ProcessKeysOptions { fnpct } % -------------------------------------------------------------------------- % MAIN INTERNAL FOOTNOTE FUNCTION: +% write the notes: \cs_new:Npn \fnpct_write_note:Nnnn #1#2#3#4 { \IfNoValueTF { #2 } @@ -159,72 +247,104 @@ } } +% check for punctuation: +\cs_new:Npn \fnpct_check_punctuation:TF #1#2 + { \fnpct_check_punctuation_auxi:nTF { 0 } { #1 } { #2 } } + +\cs_new:Npn \fnpct_check_punctuation_auxi:nTF #1#2#3 + { + \tl_set:Nx \l_fnpct_current_punct_mark_tl + { \tl_head:N \l_fnpct_punctuation_marks_tl } + \peek_meaning_remove:VTF \l_fnpct_current_punct_mark_tl + { #2 } + { + \fnpct_check_punctuation_auxii:nnn { #1 } + { \fnpct_check_punctuation_auxi:VTF \l_tmpa_int { #2 } { #3 } } + { #3 } + } + } + +\cs_new:Npn \fnpct_check_punctuation_auxii:nnn #1#2#3 + { + \int_set:Nn \l_tmpa_int { #1 } + \int_incr:N \l_tmpa_int + \tl_set:Nx \l_tmpb_tl { \int_to_arabic:n { \l_tmpa_int } } + \tl_set:Nx \l_fnpct_punctuation_marks_tl + { \tl_tail:N \l_fnpct_punctuation_marks_tl } + \tl_put_right:Nx \l_fnpct_punctuation_marks_tl + { \l_fnpct_current_punct_mark_tl } + \int_compare:nTF { \l_tmpa_int < \tl_length:V \l_fnpct_punctuation_marks_tl } + { #2 } + { #3 } + } +\cs_generate_variant:Nn \fnpct_check_punctuation_auxi:nTF { V } +\cs_generate_variant:Nn \peek_meaning_remove:NTF { V } + +% this is where the magic happens: % #1: original command % #2: optional argument of original command % #3: second optional argument of original command % #4: mandatory argument of original command % #5: boolean flag for starred version -\cs_new_protected:Npn \fnpct_dot_or_comma:Nnnnn #1#2#3#4#5 +\cs_new_protected:Npn \fnpct_handle_note:Nnnnn #1#2#3#4#5 { - % if a dot follows remove it, insert dot, skip back + % if a punctuation mark follows remove it, insert dot, skip back % and then insert footnote \fnpct_no_break: \IfBooleanT { #5 } { \bool_set_true:N \l_fnpct_dont_switch_bool } - \peek_meaning_remove:NTF . + \fnpct_check_punctuation:TF { \bool_if:nTF { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } - { . \fnpct_no_break: \skip_horizontal:N \l_fnpct_after_dot_dim } + { + \tl_use:N \l_fnpct_current_punct_mark_tl + \fnpct_no_break: + \prop_get:NVNT \l_fnpct_punctuation_marks_after_prop + \l_fnpct_current_punct_mark_tl \l_tmpa_dim + { \skip_horizontal:N \l_tmpa_dim } + } \fnpct_write_note:Nnnn #1 { #2 } { #3 } { #4 } \fnpct_write_inner:N #1 \bool_if:nT { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } - { \skip_horizontal:N \l_fnpct_before_dot_dim \fnpct_no_break: . } + { + \prop_get:NVNT \l_fnpct_punctuation_marks_before_prop + \l_fnpct_current_punct_mark_tl \l_tmpa_dim + { \skip_horizontal:N \l_tmpa_dim } + \fnpct_no_break: + \tl_use:N \l_fnpct_current_punct_mark_tl + } \bool_set_false:N \l_fnpct_dont_switch_bool } { - % else do the same with comma - \peek_meaning_remove:NTF , + % what about multiple footnotes? (their usage is discouraged with + % this package, but anyway...) + % this check should probably/maybe be removed (?!) + \tl_set:Nx \l_tmpa_tl { \cs_to_str:N #1 } + \prop_get:NVN \g_fnpct_adapted_notes_prop \l_tmpa_tl \l_tmpb_tl + \exp_args:No + \peek_meaning:NTF \l_tmpb_tl { - \bool_if:nTF { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } - { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } - { , \fnpct_no_break: \skip_horizontal:N \l_fnpct_after_comma_dim } + \bool_set_true:N \l_fnpct_multiple_footnotes_bool + % else insert space and then note + \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim \fnpct_write_note:Nnnn #1 { #2 } { #3 } { #4 } \fnpct_write_inner:N #1 - \bool_if:nT { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } - { \skip_horizontal:N \l_fnpct_before_comma_dim \fnpct_no_break: , } - \bool_set_false:N \l_fnpct_dont_switch_bool + \fnpct_no_break: + \textsuperscript { \l_fnpct_multiple_footnote_separator_tl } + % \bool_set_false:N \l_fnpct_dont_switch_bool } { - % what about multiple footnotes? (their usage is discouraged with - % this package, but anyway...) - % this check should probably/maybe be removed (?!) - \tl_set:Nx \l_tmpa_tl { \cs_to_str:N #1 } - \prop_get:NVN \g_fnpct_adapted_notes_prop \l_tmpa_tl \l_tmpb_tl - \exp_args:No - \peek_meaning:NTF \l_tmpb_tl - { - \bool_set_true:N \l_fnpct_multiple_footnotes_bool - % else insert space and then note - \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim - \fnpct_write_note:Nnnn #1 { #2 } { #3 } { #4 } - \fnpct_write_inner:N #1 - \fnpct_no_break: - \textsuperscript { \l_fnpct_multiple_footnote_separator_tl } - % \bool_set_false:N \l_fnpct_dont_switch_bool - } - { - % else insert space and then note - \bool_if:NTF \l_fnpct_multiple_footnotes_bool - { \bool_set_false:N \l_fnpct_multiple_footnotes_bool } - { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } - \fnpct_write_note:Nnnn #1 { #2 } { #3 } { #4 } - \fnpct_write_inner:N #1 - \bool_set_false:N \l_fnpct_dont_switch_bool - } + % else insert space and then note + \bool_if:NTF \l_fnpct_multiple_footnotes_bool + { \bool_set_false:N \l_fnpct_multiple_footnotes_bool } + { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } + \fnpct_write_note:Nnnn #1 { #2 } { #3 } { #4 } + \fnpct_write_inner:N #1 + \bool_set_false:N \l_fnpct_dont_switch_bool } } } -\cs_generate_variant:Nn \fnpct_dot_or_comma:Nnnnn { cnnnn } +\cs_generate_variant:Nn \fnpct_handle_note:Nnnnn { cnnnn } % -------------------------------------------------------------------------- % MULTIPLE FOOTNOTES @@ -242,49 +362,48 @@ \l_fnpct_multiple_footnotes_delimiter_tl { #3 } \fnpct_no_break: - % look for dot and do magic: - \peek_meaning_remove:NTF . + % look for punctuation mark and do magic: + \fnpct_check_punctuation:TF { \bool_if:nTF { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } - { . \fnpct_no_break: \skip_horizontal:N \l_fnpct_after_dot_dim } + { + \tl_use:N \l_fnpct_current_punct_mark_tl + \fnpct_no_break: + \prop_get:NVNT \l_fnpct_punctuation_marks_after_prop + \l_fnpct_current_punct_mark_tl \l_tmpa_dim + { \skip_horizontal:N \l_tmpa_dim } + } \fnpct_write_notes:N #1 \bool_if:nT { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } - { \skip_horizontal:N \l_fnpct_before_dot_dim \fnpct_no_break: . } + { + \prop_get:NVNT \l_fnpct_punctuation_marks_before_prop + \l_fnpct_current_punct_mark_tl \l_tmpa_dim + { \skip_horizontal:N \l_tmpa_dim } + \fnpct_no_break: + \tl_use:N \l_fnpct_current_punct_mark_tl + } \bool_set_false:N \l_fnpct_dont_switch_bool } { - % else look for comma and do magic: - \peek_meaning_remove:NTF , + % else insert space and notes: + \tl_set:Nx \l_tmpa_tl { \cs_to_str:N #1 } + \prop_get:NVN \g_fnpct_adapted_notes_prop \l_tmpa_tl \l_tmpb_tl + \exp_args:No + \peek_meaning:NTF \l_tmpb_tl { - \bool_if:nTF { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } - { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } - { , \fnpct_no_break: \skip_horizontal:N \l_fnpct_after_comma_dim } + \bool_set_true:N \l_fnpct_multiple_footnotes_bool + \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim \fnpct_write_notes:N #1 - \bool_if:nT { \l_fnpct_punct_after_bool || \l_fnpct_dont_switch_bool } - { \skip_horizontal:N \l_fnpct_before_comma_dim \fnpct_no_break: , } \bool_set_false:N \l_fnpct_dont_switch_bool + \textsuperscript { \l_fnpct_multiple_footnote_separator_tl } } { - % else insert space and notes: - \tl_set:Nx \l_tmpa_tl { \cs_to_str:N #1 } - \prop_get:NVN \g_fnpct_adapted_notes_prop \l_tmpa_tl \l_tmpb_tl - \exp_args:No - \peek_meaning:NTF \l_tmpb_tl - { - \bool_set_true:N \l_fnpct_multiple_footnotes_bool - \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim - \fnpct_write_notes:N #1 - \bool_set_false:N \l_fnpct_dont_switch_bool - \textsuperscript { \l_fnpct_multiple_footnote_separator_tl } - } - { - \bool_if:NTF \l_fnpct_multiple_footnotes_bool - { \bool_set_false:N \l_fnpct_multiple_footnotes_bool } - { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } - \fnpct_write_notes:N #1 - \bool_set_false:N \l_fnpct_dont_switch_bool - } + \bool_if:NTF \l_fnpct_multiple_footnotes_bool + { \bool_set_false:N \l_fnpct_multiple_footnotes_bool } + { \fnpct_no_break: \skip_horizontal:N \l_fnpct_before_footnote_dim } + \fnpct_write_notes:N #1 + \bool_set_false:N \l_fnpct_dont_switch_bool } } } @@ -447,7 +566,7 @@ { \cs_set_eq:NN #1 #3 } { \RenewDocumentCommand #1 { so+m } - { \fnpct_dot_or_comma:Nnnnn #2 { ##2 } { \NoValue } { ##3 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { ##2 } { \NoValue } { ##3 } { ##1 } } } } \cs_generate_variant:Nn \fnpct_renew_and_mult:NNN { ccc , NcN } @@ -461,7 +580,7 @@ { \cs_set_eq:NN #1 #3 } { \RenewDocumentCommand #1 { s+m } - { \fnpct_dot_or_comma:Nnnnn #2 { \NoValue } { \NoValue } { ##2 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { \NoValue } { \NoValue } { ##2 } { ##1 } } } } \cs_generate_variant:Nn \fnpct_renew_and_mult_no_opt:NNN { ccc } @@ -472,7 +591,7 @@ \prop_gput:Nxn \g_fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } \cs_new_eq:NN #2 #1 \RenewDocumentCommand #1 { so+m } - { \fnpct_dot_or_comma:Nnnnn #2 { ##2 } { \NoValue } { ##3 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { ##2 } { \NoValue } { ##3 } { ##1 } } } \cs_generate_variant:Nn \fnpct_renew:NN { cc ,Nc } @@ -481,7 +600,7 @@ { \prop_gput:Nxn \g_fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } \NewDocumentCommand #1 { so+m } - { \fnpct_dot_or_comma:Nnnnn #2 { ##2 } { \NoValue } { ##3 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { ##2 } { \NoValue } { ##3 } { ##1 } } } \cs_generate_variant:Nn \fnpct_new:NN { cc , Nc } @@ -495,7 +614,7 @@ { \cs_set_eq:NN #1 #3 } { \RenewDocumentCommand #1 { soo+m } - { \fnpct_dot_or_comma:Nnnnn #2 { ##2 } { ##3 } { ##4 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { ##2 } { ##3 } { ##4 } { ##1 } } } } \cs_generate_variant:Nn \fnpct_renew_and_mult_opt:NNN { ccc , NcN } @@ -505,7 +624,7 @@ \prop_gput:Nxn \g_fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } \cs_new_eq:NN #2 #1 \RenewDocumentCommand #1 { soo+m } - { \fnpct_dot_or_comma:Nnnnn #2 { ##2 } { ##3 } { ##4 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { ##2 } { ##3 } { ##4 } { ##1 } } } \cs_generate_variant:Nn \fnpct_renew_opt:NN { cc , Nc } @@ -515,7 +634,7 @@ \prop_gput:Nxn \g_fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } \cs_new_eq:NN #2 #1 \RenewDocumentCommand #1 { s+m } - { \fnpct_dot_or_comma:Nnnnn #2 { \NoValue } { \NoValue } { ##2 } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { \NoValue } { \NoValue } { ##2 } { ##1 } } } \cs_generate_variant:Nn \fnpct_renew_no_opt:NN { cc ,Nc } @@ -525,7 +644,7 @@ \prop_gput:Nxn \g_fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } \cs_new_eq:NN #2 #1 \RenewDocumentCommand #1 { s } - { \fnpct_dot_or_comma:Nnnnn #2 { \NoValue } { \NoValue } { } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { \NoValue } { \NoValue } { } { ##1 } } } \cs_generate_variant:Nn \fnpct_renew_no_arg:NN { cc } @@ -542,7 +661,7 @@ \prop_gput:Nxn \g_fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } \cs_new_eq:NN #2 #1 \RenewDocumentCommand #1 { so } - { \fnpct_dot_or_comma:Nnnnn #2 { ##2 } { \NoValue } { } { ##1 } } + { \fnpct_handle_note:Nnnnn #2 { ##2 } { \NoValue } { } { ##1 } } } \cs_generate_variant:Nn \fnpct_renew_mark:NN { cc , Nc } @@ -773,6 +892,8 @@ - better support for citing commands - error checking in the \Adapt commands - package option `strict' +2012/05/26 v0.2 - added possibility to add punctuation marks to the + switching/kerning mechansim (or remove them) % -------------------------------------------------------------------------- % NOTES: @@ -781,4 +902,4 @@ % -------------------------------------------------------------------------- % TODO: -- solve incompatibility with the `footnote' package +- solve incompatibility with the `footnote' package \ No newline at end of file -- cgit v1.2.3