Design semelhante a tufte com notas laterais cruzando quebras de página, ou: Tufte feito com KOMA-Script

Design semelhante a tufte com notas laterais cruzando quebras de página, ou: Tufte feito com KOMA-Script

Pelo que entendi (corrija-me se estiver errado), uma desvantagem das classes tufte é que as notas laterais não podem cruzar uma quebra de página. As notas laterais devem terminar na mesma página onde começam.

Percebi que uma versão bastante atual do KOMA-Script inclui um pacote scrlayer-notecolumn, que resolve esse problema: podemos ter notas laterais independentemente das quebras de página.

As notas laterais até funcionam dentro de carros alegóricos, mas a numeração das notas laterais é um problema.

Podemos ter tabulares e figuras na margem, mas cada comando na margem precisa de um arquivo \protect.

Pergunta: Como escrever um ambiente margintabularcomo nas aulas de tufte? O que mais precisamos para melhorar os documentos no estilo Tufte com o scrlayer-notecolumnpacote?

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage, scrlayer-notecolumn, lmodern, blindtext,
ragged2e}

%% step 1: counter
\newcounter{snmark}
\setcounter{snmark}{0}


%% step 2: hanging sidenotes, definition from tugboat
\makeatletter
\newcommand*{\hangfrom}[1]{%
  \setbox\@tempboxa\hbox{{#1}}%
  \hangindent \wd\@tempboxa
  \noindent\box\@tempboxa}
\makeatletter

%% step 3: define sidenote marks in the text
\newcommand{\makesidenotemark}{%
  \textsuperscript{\thesnmark}
}%


%% step 4: and now the definition of sidenotes
\newcommand{\sidenote}[1]{%
  \refstepcounter{snmark}% Zähler erhöhen
  \makesidenotemark{}% Nummer im Text setzen.
  \makenote[paragraphs]{%
    \hangfrom{%
      \makebox[1em][l]{%
        \thesnmark}
            }
        \protect\RaggedRight{} #1}% Text setzen im Rand
}


%% this is, except for the values (».7«) from scrguide.pdf to define
%% the notecolumn.

\newlength{\paragraphscolwidth}
\AfterCalculatingTypearea{%
\setlength{\paragraphscolwidth}{.4\textwidth}%
\addtolength{\paragraphscolwidth}{-\marginparsep}%
}
\recalctypearea
\DeclareNewNoteColumn[%
position=\oddsidemargin+1in
+.7\textwidth
+\marginparsep,
width=\paragraphscolwidth,
font=\footnotesize
]{paragraphs}





%% Delete all sidenotes:
%\renewcommand{\sidenote}[1]{\relax}

\begin{document}
\begin{addmargin}[0pt]{.3\textwidth}
  This is the text with a \sidenote{See here.\blindtext}.
  \blindtext


  And here we have a second paragraph and a second
  sidenote\sidenote{\blindtext}.
  \blindtext

  And this is the big hit: We can have sidenotes which include
  pagebreaks!\sidenote{Proof of concept: \blindtext{}}


  \syncwithnotecolumns[paragraphs]

      And now we somewhere have a table:
  \begin{table}[b]
    \centering
    \begin{tabular}{ll}
      Proof\sidenote{From inside the float} & of concept\\
    \end{tabular}
    \caption{This is a table}
    \label{tab:table}
  \end{table}

Besides that, we even can have tabulars in the margin\sidenote{%
  Tabular in the margin:

  \protect\begin{tabular}{|l|l|}\protect\hline
    a& b\\\protect\hline
    a& b\\\protect\hline
    a& b\\\protect\hline
  \protect\end{tabular}
}, but they have
to be narrow and well protected.

\end{addmargin}


\end{document}

Responder1

Para ter tabelas dentro da nota de margem, você poderia criar um tipo de ambiente de tabela não flutuante, por exemplo

\usepackage{environ}
\makeatletter
\NewEnviron{margintable}{%
  \expandafter\@margintable\expandafter{\BODY}%
}
\newcommand*\@margintable[1]{%
  \makenote[paragraphs]{%
    \protect\begin{nonfloattable}\detokenize{#1}\protect\end{nonfloattable}
  }%
}
\newenvironment{nonfloattable}{%
  \par\noindent\begin{minipage}{\linewidth}
    \def\@captype{table}%
}{%
  \end{minipage}\par
}

Mas há um problema: parece que escrever um rótulo no aux-file de dentro de uma nota não funciona, então \label{tab:secondtable}dentro de um margintableambiente não resultaria em um rótulo.

Estranho: escrever a legenda no auxarquivo funciona.

Atualmente não sei por que escrever o rótulo no auxarquivo não funciona, mas escrever a lotentrada no auxarquivo funciona. No entanto, você poderia usar um hack para escrever as informações do rótulo no aux-file ao usar, margintableem vez de ao fazer a anotação:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage, scrlayer-notecolumn, lmodern, blindtext,
ragged2e}

%% step 1: counter
\newcounter{snmark}
\setcounter{snmark}{0}


%% step 2: hanging sidenotes, definition from tugboat
\makeatletter
\newcommand*{\hangfrom}[1]{%
  \setbox\@tempboxa\hbox{{#1}}%
  \hangindent \wd\@tempboxa
  \noindent\box\@tempboxa}
\makeatletter

%% step 3: define sidenote marks in the text
\newcommand{\makesidenotemark}{%
  \textsuperscript{\thesnmark}
}%


%% step 4: and now the definition of sidenotes
\newcommand{\sidenote}[1]{%
  \refstepcounter{snmark}% Zähler erhöhen
  \makesidenotemark{}% Nummer im Text setzen.
  \makenote[paragraphs]{%
    \hangfrom{%
      \makebox[1em][l]{%
        \thesnmark}
            }
        \protect\RaggedRight{} #1}% Text setzen im Rand
}


%% this is, except for the values (».7«) from scrguide.pdf to define
%% the notecolumn.

\newlength{\paragraphscolwidth}
\AfterCalculatingTypearea{%
\setlength{\paragraphscolwidth}{.4\textwidth}%
\addtolength{\paragraphscolwidth}{-\marginparsep}%
}
\recalctypearea
\DeclareNewNoteColumn[%
position=\oddsidemargin+1in
+.7\textwidth
+\marginparsep,
width=\paragraphscolwidth,
font=\footnotesize
]{paragraphs}

\usepackage{environ}
\makeatletter
\NewEnviron{margintable}{%
  \expandafter\@margintable\expandafter{\BODY}%
}
\newcommand*\@margintable[1]{%
  \global\let\labeltoset\@empty
  \@tempcnta\value{table}%
  \begin{lrbox}{\@tempboxa}
    \begin{minipage}{\paragraphscolwidth}
      \def\label##1{%
        \xdef\labeltoset{%
          \labeltoset
          \noexpand\protected@write\noexpand\@auxout{}{%
            \noexpand\string\noexpand\newlabel{##1}{{\@currentlabel}{\thepage}}}%
        }%
      }%
      \def\@captype{table}%
      #1%
    \end{minipage}
  \end{lrbox}%
  \setcounter{table}{\@tempcnta}%
  \makenote[paragraphs]{%
    \protect\begin{nonfloattable}\detokenize{#1}\protect\end{nonfloattable}
  }%
  \labeltoset
}
\newenvironment{nonfloattable}{%
  \par\noindent\begin{minipage}{\linewidth}
    \def\@captype{table}%
}{%
  \end{minipage}\par
}

%% Delete all sidenotes:
%\renewcommand{\sidenote}[1]{\relax}

\begin{document}
\begin{addmargin}[0pt]{.3\textwidth}
  This is the text with a \sidenote{See here.\blindtext}.
  \blindtext


  And here we have a second paragraph and a second
  sidenote\sidenote{\blindtext}.
  \blindtext

  And this is the big hit: We can have sidenotes which include
  pagebreaks!\sidenote{Proof of concept: \blindtext{}}


  \syncwithnotecolumns[paragraphs]

      And now we somewhere have a table:
  \begin{table}[b]
    \centering
    \begin{tabular}{ll}
      Proof\sidenote{From inside the float} & of concept\\
    \end{tabular}
    \caption{This is a table}
    \label{tab:table}
  \end{table}

Besides that, we even can have tabulars in the margin\sidenote{%
  Tabular in the margin:

  \protect\begin{tabular}{|l|l|}\protect\hline
    a& b\\\protect\hline
    a& b\\\protect\hline
    a& b\\\protect\hline
  \protect\end{tabular}
}, but they have
to be narrow and well protected.

\begin{margintable}
  \centering
  \begin{tabular}{|l|l|}\hline
    a& b\\\hline
    a& b\\\hline
    a& b\\\hline
  \end{tabular}
  \caption{This is a second table}%
  \label{tab:secondtable}
\end{margintable}

See also table~\ref{tab:secondtable}.

\end{addmargin}

\listoftables

\end{document}

Mas observe que ainda há um problema: o número da página da etiqueta estará errado se a nota passar para outra página.


Atualização: De scrlayer-notecolumn0.1.2583 deKOMA-Script 3.23.2583 \labelnas notas funciona conforme o esperado. E com o novo \makenote*você não precisa \protectmais de tudo isso. Então o seguinte funciona:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage, scrlayer-notecolumn, lmodern, blindtext,
ragged2e}

%% step 1: counter
\newcounter{snmark}
\setcounter{snmark}{0}


%% step 2: hanging sidenotes, definition from tugboat
\makeatletter
\newcommand*{\hangfrom}[1]{%
  \setbox\@tempboxa\hbox{{#1}}%
  \hangindent \wd\@tempboxa
  \noindent\box\@tempboxa}
\makeatletter

%% step 3: define sidenote marks in the text
\newcommand{\makesidenotemark}{%
  \textsuperscript{\thesnmark}%
}%


%% step 4: and now the definition of sidenotes
\newcommand{\sidenote}[1]{%
  \refstepcounter{snmark}% Zähler erhöhen
  \makesidenotemark{}% Nummer im Text setzen.
  \makenote[paragraphs]{%
    \hangfrom{%
      \makebox[1em][l]{%
        \thesnmark}%
    }%
    \protect\RaggedRight\detokenize{#1}}% Text setzen im Rand
}


%% this is, except for the values (».7«) from scrguide.pdf to define
%% the notecolumn.

\newlength{\paragraphscolwidth}
\AfterCalculatingTypearea{%
\setlength{\paragraphscolwidth}{.4\textwidth}%
\addtolength{\paragraphscolwidth}{-\marginparsep}%
}
\recalctypearea
\DeclareNewNoteColumn[%
position=\oddsidemargin+1in
+.7\textwidth
+\marginparsep,
width=\paragraphscolwidth,
font=\footnotesize
]{paragraphs}

\usepackage{environ}
\makeatletter
\NewEnviron{margintable}{%
  \expandafter\@margintable\expandafter{\BODY}%
}
\newcommand*\@margintable[1]{%
  \makenote*[paragraphs]{%
    \begin{nonfloattable}#1\end{nonfloattable}%
  }%
}
\newenvironment{nonfloattable}{%
  \par\noindent\begin{minipage}{\linewidth}
    \def\@captype{table}%
}{%
  \end{minipage}\par
}
\usepackage{makeidx}

%% Delete all sidenotes:
%\renewcommand{\sidenote}[1]{\relax}

\begin{document}
\begin{addmargin}[0pt]{.3\textwidth}
  This is the text with a sidenote\sidenote{See here.\blindtext}.
  \blindtext


  And here we have a second paragraph and a second
  sidenote\sidenote{\blindtext}.
  \blindtext

  And this is the big hit: We can have sidenotes which include
  pagebreaks!\sidenote{Proof of concept: \blindtext{}}


  \syncwithnotecolumns[paragraphs]

      And now we somewhere have a table:
  \begin{table}[b]
    \centering
    \begin{tabular}{ll}
      Proof\sidenote{From inside the float} & of concept\\
    \end{tabular}
    \caption{This is a table}
    \label{tab:table}
  \end{table}

Besides that, we even can have tabulars in the margin\sidenote{%
  Tabular in the margin:

  \begin{tabular}{|l|l|}\hline
    a& b\\\hline
    a& b\\\hline
    a& b\\\hline
  \end{tabular}%
}, but they have
to be narrow and well protected.

\begin{margintable}
  \centering
  \begin{tabular}{|l|l|}\hline
    a& b\\\hline
    a& b\\\hline
    a& b\\\hline
  \end{tabular}
  \caption{This is a second table}%
  \label{tab:secondtable}
\end{margintable}

See also table~\ref{tab:secondtable}.
\listoftables

\end{addmargin}


\end{document}

Pois \sidenotevocê não pode usar \makenote*, porque \thesnmarkprecisa ser expandido imediatamente. Mas você mesmo pode usar o \detokenizetruque \makenote*mostrado no exemplo acima.

BTW: No código acima corrigi vários erros de espaço.

informação relacionada