4

I am finishing off a table for a report and noticed one of the footmark marks protruding into the margin (MWE image):

enter image description here

Footnote mark B is protruding and I do not know how to force it to be considered as part of protein, I tried wrapping them both in {protein\tabularnote{...}} for what it was worth but that achieved nothing. How can I make the B footnote mark not protrude into the page margin please?

Removing words is likely not possible as I have minimized the sentence down to the bare essentials and if I add more the section 2000-04 goes into 5 lines total rather then 4 and takes up too much room (the table just fits nicely at the bottom with an image at top and some main body text in the middle). Changing the order would break the chronology so I am not sure what to do. (note: the text in the table is not the same as my report with biblatex \cite{...} etc and custom commands \denovo\ that I removed for the MWE, I just added filler stuff to showcase the issue).

In the MWE, I compiled with pdflatex 3 times as I am using nicematrix, in my actual document my table is more involved than the MWE so nicematrix is needed.

MWE:

\documentclass[oneside]{book}

\usepackage{lipsum} % for dummy text

\usepackage[a4paper,inner=2.5cm,outer=2.5cm,top=3cm,bottom=3cm]{geometry} \usepackage{booktabs} \usepackage{nicematrix} \usepackage{enumitem}

\begin{document}

\begin{table}[tb] \caption{\lipsum[1][1]} \footnotesize \NiceMatrixOptions { notes = { para, enumitem-keys-para = { itemjoin = ;; }, bottomrule, style = {\textit{\Alph{#1}}}, } } \begin{NiceTabularX}{\textwidth}{@{} c @{\hspace{4pt}} X @{}} \toprule \textbf{Year} & \textbf{\lipsum[1][1]}\ \midrule 2000--04 & First \textit{de novo} metalloproteins described with a minimal-model diiron protein\tabularnote{2000} (17), \textit{de novo} diiron diiron protein\tabularnote{2002} (18) and \textit{de novo} diiron phenol oxidase\tabularnote{2004} (19). First computational design procedure.\ \addlinespace[0.1em] \bottomrule \end{NiceTabularX} \end{table}

\end{document}

My search on this sites previous questions didn't yield much, mainly questions that involved different packages or methods like footnote goes over margin. If this is a duplicate or there is a similar issue differently worded I would appreciate link if possible please.

JamesT
  • 3,169
  • 1
    There's always the terrible hack of a forced line break before "protein". A method that ties the footnote mark to its referent would be better, of course. – barbara beeton Jun 17 '23 at 14:54
  • you can use a box protein\mbox{\tabularnote{2002}}. – Ulrike Fischer Jun 17 '23 at 14:56
  • @UlrikeFischer thank you very much, I didn't even consider that! Worked perfectly, if you want to post an answer I will accept or in a few days I will post a wiki answer if not, now I know for the future to try \mbox – JamesT Jun 17 '23 at 14:58
  • 1
    \mbox{protein\tabularnote{2002}\strut} will do, so long as you don't want the line to break in the mibble of protein. – John Kormylo Jun 17 '23 at 18:45

3 Answers3

5

The nicematrix package set the note number in a \rlap-box and adds a space behind it. At the end of a line this space disappears and the box sticks into the margin. You can save the space by putting the note in a box: protein\mbox{\tabularnote{2002}}

Ulrike Fischer
  • 327,261
3

Package nicematrix uses

\hbox_overlap_right:n { \box_use:N \l_tmpa_box }
\skip_horizontal:n { \box_wd:N \l_tmpa_box }

to explicitly set the footnote number into the margin, because \hbox_overlap_right:n prints the content to the right but without width (you may know this as \rlap) and the \skip_horizontal:n (which is a \hskip) is ignored at the end of the line. If you never want this kind of protrusion you can patch nicematrix to use

\box_use:N \l_tmpa_box

instead:

\documentclass[oneside]{book}

\usepackage{lipsum} % for dummy text

\usepackage[a4paper,inner=2.5cm,outer=2.5cm,top=3cm,bottom=3cm]{geometry} \usepackage{booktabs} \usepackage{nicematrix} \usepackage{enumitem} \usepackage{xpatch} \ExplSyntaxOn \xpatchcmd{__nicematrix_tabularnote:nn}{% \hbox_overlap_right:n { \box_use:N \l_tmpa_box } \skip_horizontal:n { \box_wd:N \l_tmpa_box } }{% \box_use:N \l_tmpa_box }{}{\PatchFailure} \ExplSyntaxOff

\begin{document}

\begin{table}[tb] \caption{\lipsum[1][1]} \footnotesize \NiceMatrixOptions { notes = { para, enumitem-keys-para = { itemjoin = ;; }, bottomrule, style = {\textit{\Alph{#1}}}, } } \begin{NiceTabularX}{\textwidth}{@{} c @{\hspace{4pt}} X @{}} \toprule \textbf{Year} & \textbf{\lipsum[1][1]}\ \midrule 2000--04 & First \textit{de novo} metalloproteins described with a minimal-model diiron protein\tabularnote{2000} (17), \textit{de novo} diiron diiron protein\tabularnote{2002} (18) and \textit{de novo} diiron phenol oxidase\tabularnote{2004} (19). First computational design procedure.\ \addlinespace[0.1em] \bottomrule \end{NiceTabularX} \end{table}

\end{document}

result with the patch

cabohah
  • 11,455
  • +1, thank you for the answer, I went with Ulrike's per my comment on the Q but I appreciate the extra backgrounds, think I need to learn latex3, thanks! – JamesT Jun 17 '23 at 17:28
1

I have modified nicematrix to address that problem. In the latest version (6.20a 2023-06-30) the mechanism described in cabohah's answer (in order to have the footnote's number protruding in the right margin) is activated only when the alignment mode of the column is c or r.

Hence, in your case, you have directly the expected output.

\documentclass[oneside]{book}

\usepackage{lipsum} % for dummy text

\usepackage[a4paper,inner=2.5cm,outer=2.5cm,top=3cm,bottom=3cm]{geometry} \usepackage{booktabs} \usepackage{nicematrix} \usepackage{enumitem}

\begin{document}

\begin{table}[tb] \caption{\lipsum[1][1]} \footnotesize \NiceMatrixOptions { notes = { para, enumitem-keys-para = { itemjoin = ;; }, bottomrule, style = {\textit{\Alph{#1}}}, } } \begin{NiceTabularX}{\textwidth}{@{} c @{\hspace{4pt}} X @{}} \toprule \textbf{Year} & \textbf{\lipsum[1][1]}\ \midrule 2000--04 & First \textit{de novo} metalloproteins described with a minimal-model diiron protein\tabularnote{2000} (17), \textit{de novo} diiron diiron protein\tabularnote{2002} (18) and \textit{de novo} diiron phenol oxidase\tabularnote{2004} (19). First computational design procedure.\ \addlinespace[0.1em] \bottomrule \end{NiceTabularX} \end{table}

\end{document}

Output of the above code

F. Pantigny
  • 40,250