ctansearch
21-03-2014, 01:53
Ich habe eine tabrefnotes.sty erstellt, die in Tabellen eine Referenzierung von Zellen erlaubt. Diese werden mit tabrows und tabcols bezeichnet und können per thetabrefnotes[] angezeigt werden. Was nun noch fehlt, ist eine Funktion, diese Referenzen im Fließtext verfügbar zu machen. Das Kernproblem ist durch %bezug definieren angezeigt.
% ****************************************
% * tabrefnotes
% ****************************************
%
% Date of this version: 2014-03-19
% Matthias Borck-Elsner
%
%% Based on endnotes.sty Copyright 2002 John Lavagnino
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The lambe version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%%
%% ****************************************
%% * tabrefnote MACROS *
%% ****************************************
\newcounter{tabcols}%relevant
\newcounter{tabrows}%relevant
\@definecounter{tabrefnote}%
\newcommand{\trfl}{\\\stepcounter{tabrows}\setcoun ter{tabcols}{0}}
\def\thetabrefnote{\@arabic\c@tabrefnote}%
\def\@maketabrefmark{\hbox{{{\textsuperscript{\tin y(\@thetabrefmark)}}}}}%
\def\maketabrefmark{\@maketabrefmark}%
\def\thetabrefmark{\@thetabrefmark}%
\newdimen\tabrefnotesep%
\def\tabrefnote{\@ifnextchar[\@xtabrefnote{\stepcounter{tabrefnote}%
\protected@xdef\@thetabrefmark{\thetabrefnote}%
\@tabrefnotemark\@tabrefnotetext}}%
\def\@xtabrefnote[#1]{%
\begingroup%
\c@tabrefnote=#1\relax%
\unrestored@protected@xdef\@thetabrefmark{\thetabr efnote}%
\endgroup%
\@tabrefnotemark\@tabrefnotetext}%
\let\@doantabrefnote=0%
\let\@endantabrefnote=0%
\newwrite\@tabrefnotes%
\newif\if@tabrefnotesopen\global\@tabrefnotesopenf alse%
\def\@opentabrefnotes{\immediate\openout\@tabrefno tes=\jobname.tabref\relax%
\global\@tabrefnotesopentrue}%
\long\def\@tabrefnotetext#1{% %relevant #2 um tabcols heraufzusetzen
\stepcounter{tabcols}%
\if@tabrefnotesopen \else\@opentabrefnotes\fi%
\immediate\write\@tabrefnotes{\@doantabrefnote{(\@ thetabrefmark)%
\thetable.\thetabrows.\thetabcols }}%%relevant zur Ausgabe der rows und cols
\begingroup%
\def\tabrefnote{#1\ }%
%%%%%%%%%%%%%%
%bezug definieren?
\xdef\test{\noexpand\textsl{test
\thetable.\thetabrows.\thetabcols}\ }%relevant zur definition des Bezugs
%bezug definieren?
%%%%%%%%%%%%%%%
\newlinechar='40%
\immediate\write\@tabrefnotes{\meaning\tabrefnote} %
\endgroup%
\immediate\write\@tabrefnotes{\@endantabrefnote}}%
\long\def\addtotabrefnotes#1{%
\if@tabrefenotesopen\else\@opentabrefnotes\fi%
\begingroup%
\newlinechar='40%
\let\protect\string%
\immediate\write\@tabrefnotes{#1}%
\endgroup}%
\def\tabrefnotemark{%
\@ifnextchar[\@xtabrefnotemark%
{\stepcounter{tabrefnote}%
\protected@xdef\@thetabrefmark{\thetabrefnote}%
\@tabrefnotemark}}%
\def\@xtabrefnotemark[#1]{%
\begingroup%
\c@tabrefnote #1\relax%
\unrestored@protected@xdef\@thetabrefmark{\thetabr efnote}%
\endgroup%
\@tabrefnotemark}%
%
\def\@tabrefnotemark{%
\leavevmode%
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi%
\maketabrefmark%
\ifhmode\spacefactor\@x@sf\fi%
\relax}%
%
\def\tabrefnotetext{%
\@ifnextchar [\@xtabrefnotenext%
{\protected@xdef\@thetabrefmark{\thetabrefnote}%
\@tabrefnotetext}}%
%
\def\@xtabrefnotenext[#1]{\begingroup \c@tabrefnote=#1\relax%
\xdef\@thetabrefmark{\thetabrefnote}\endgroup\@tab refnotetext}%
%
\def\@xtabrefnotenext[#1]{%
\begingroup%
\c@tabrefnote=#1\relax%
\unrestored@protected@xdef\@thetabrefmark{\thetabr efnote}%
\endgroup%
\@tabrefnotetext}%
\def\tabrefnotesname{tabrefnotes} %
\def\tabrefnoteheading{\subsection*{\footnotesize{ \tabrefnotesname} \@mkboth{\MakeUppercase{\tabrefnotesname}}{\MakeUp percase{\tabrefnotesname}}}%
}%
\def\tabrefnoteformat{%
\leavevmode\llap{\maketabrefmark}}%%
\def\tabrefnotesize{\scriptsize}%%relevant für Größe der tabrefnote in \thetabrefnotes
\def\thetabrefnotes[#1]{\def\tabrefnotesname{#1}\immediate\closeout\@tabr efnotes \global\@tabrefnotesopenfalse%
\begingroup%
\makeatletter%
\edef\@tempa{`\string >}%
\ifnum\catcode\@tempa=12%
\let\@ResetGT\relax%
\else%
\edef\@ResetGT{\noexpand\catcode\@tempa=\the\catco de\@tempa}%
\@makeother\>%
\fi%
\def\@doantabrefnote##1##2>{\def\@thetabrefmark{##1}\begingroup%
\@ResetGT%
\edef\@currentlabel{\csname p@tabrefnote\endcsname\@thetabrefmark}%
\tabrefnoteformat}%
\def\@endantabrefnote{\endgroup}%
\tabrefnoteheading %
\tabrefnotesize%
\input{\jobname.tabref}%
\setcounter{tabrefnote}{0} %
\setcounter{tabrows}{0} %
\setcounter{tabcols}{0} %
\endgroup}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%
tabrefnotes.tex
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx,longtable,tabrefnote}
\usepackage{xcolor}
\parindent=0pt
\begin{document}
\section{Dummy}
Ein Text vor dem Problem.
\section{longtable}
\begin{longtable}[l]{p{2cm}p{2cm}p{2cm}}\caption{First}\\
Zähler&Nenner&Bruch\trfl
1\tabrefnote{null}&2&$\frac{1}{2}$\trfl
1\tabrefnote{Atest}&2\tabrefnote{Btest}&$\frac{1}{2}$\tabrefnote{Ctest}\trfl
1\tabrefnote{Dtest}&2\tabrefnote{Etest}&$\frac{1}{2}$\tabrefnote{Ftest}\trfl
1&2&$\frac{1}{2}$\trfl
\thetabrefnotes[]
\end{longtable}
\begin{longtable}[l]{p{2cm}p{2cm}p{2cm}}\caption{First}\\
Zähler&Nenner&Bruch\trfl
1\tabrefnote{null}&2&$\frac{1}{2}$\trfl
1\tabrefnote{Atest}&2\tabrefnote{Btest}&$\frac{1}{2}$\tabrefnote{Ctest}\trfl
1\tabrefnote{Dtest}&2\tabrefnote{Etest}&$\frac{1}{2}$\tabrefnote{Ftest}\trfl
1&2&$\frac{1}{2}$\trfl
\thetabrefnotes[]
\end{longtable}
\section{Dummy}
Ein Text \test nach dem Problem.
\end{document}
% ****************************************
% * tabrefnotes
% ****************************************
%
% Date of this version: 2014-03-19
% Matthias Borck-Elsner
%
%% Based on endnotes.sty Copyright 2002 John Lavagnino
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The lambe version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%%
%% ****************************************
%% * tabrefnote MACROS *
%% ****************************************
\newcounter{tabcols}%relevant
\newcounter{tabrows}%relevant
\@definecounter{tabrefnote}%
\newcommand{\trfl}{\\\stepcounter{tabrows}\setcoun ter{tabcols}{0}}
\def\thetabrefnote{\@arabic\c@tabrefnote}%
\def\@maketabrefmark{\hbox{{{\textsuperscript{\tin y(\@thetabrefmark)}}}}}%
\def\maketabrefmark{\@maketabrefmark}%
\def\thetabrefmark{\@thetabrefmark}%
\newdimen\tabrefnotesep%
\def\tabrefnote{\@ifnextchar[\@xtabrefnote{\stepcounter{tabrefnote}%
\protected@xdef\@thetabrefmark{\thetabrefnote}%
\@tabrefnotemark\@tabrefnotetext}}%
\def\@xtabrefnote[#1]{%
\begingroup%
\c@tabrefnote=#1\relax%
\unrestored@protected@xdef\@thetabrefmark{\thetabr efnote}%
\endgroup%
\@tabrefnotemark\@tabrefnotetext}%
\let\@doantabrefnote=0%
\let\@endantabrefnote=0%
\newwrite\@tabrefnotes%
\newif\if@tabrefnotesopen\global\@tabrefnotesopenf alse%
\def\@opentabrefnotes{\immediate\openout\@tabrefno tes=\jobname.tabref\relax%
\global\@tabrefnotesopentrue}%
\long\def\@tabrefnotetext#1{% %relevant #2 um tabcols heraufzusetzen
\stepcounter{tabcols}%
\if@tabrefnotesopen \else\@opentabrefnotes\fi%
\immediate\write\@tabrefnotes{\@doantabrefnote{(\@ thetabrefmark)%
\thetable.\thetabrows.\thetabcols }}%%relevant zur Ausgabe der rows und cols
\begingroup%
\def\tabrefnote{#1\ }%
%%%%%%%%%%%%%%
%bezug definieren?
\xdef\test{\noexpand\textsl{test
\thetable.\thetabrows.\thetabcols}\ }%relevant zur definition des Bezugs
%bezug definieren?
%%%%%%%%%%%%%%%
\newlinechar='40%
\immediate\write\@tabrefnotes{\meaning\tabrefnote} %
\endgroup%
\immediate\write\@tabrefnotes{\@endantabrefnote}}%
\long\def\addtotabrefnotes#1{%
\if@tabrefenotesopen\else\@opentabrefnotes\fi%
\begingroup%
\newlinechar='40%
\let\protect\string%
\immediate\write\@tabrefnotes{#1}%
\endgroup}%
\def\tabrefnotemark{%
\@ifnextchar[\@xtabrefnotemark%
{\stepcounter{tabrefnote}%
\protected@xdef\@thetabrefmark{\thetabrefnote}%
\@tabrefnotemark}}%
\def\@xtabrefnotemark[#1]{%
\begingroup%
\c@tabrefnote #1\relax%
\unrestored@protected@xdef\@thetabrefmark{\thetabr efnote}%
\endgroup%
\@tabrefnotemark}%
%
\def\@tabrefnotemark{%
\leavevmode%
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi%
\maketabrefmark%
\ifhmode\spacefactor\@x@sf\fi%
\relax}%
%
\def\tabrefnotetext{%
\@ifnextchar [\@xtabrefnotenext%
{\protected@xdef\@thetabrefmark{\thetabrefnote}%
\@tabrefnotetext}}%
%
\def\@xtabrefnotenext[#1]{\begingroup \c@tabrefnote=#1\relax%
\xdef\@thetabrefmark{\thetabrefnote}\endgroup\@tab refnotetext}%
%
\def\@xtabrefnotenext[#1]{%
\begingroup%
\c@tabrefnote=#1\relax%
\unrestored@protected@xdef\@thetabrefmark{\thetabr efnote}%
\endgroup%
\@tabrefnotetext}%
\def\tabrefnotesname{tabrefnotes} %
\def\tabrefnoteheading{\subsection*{\footnotesize{ \tabrefnotesname} \@mkboth{\MakeUppercase{\tabrefnotesname}}{\MakeUp percase{\tabrefnotesname}}}%
}%
\def\tabrefnoteformat{%
\leavevmode\llap{\maketabrefmark}}%%
\def\tabrefnotesize{\scriptsize}%%relevant für Größe der tabrefnote in \thetabrefnotes
\def\thetabrefnotes[#1]{\def\tabrefnotesname{#1}\immediate\closeout\@tabr efnotes \global\@tabrefnotesopenfalse%
\begingroup%
\makeatletter%
\edef\@tempa{`\string >}%
\ifnum\catcode\@tempa=12%
\let\@ResetGT\relax%
\else%
\edef\@ResetGT{\noexpand\catcode\@tempa=\the\catco de\@tempa}%
\@makeother\>%
\fi%
\def\@doantabrefnote##1##2>{\def\@thetabrefmark{##1}\begingroup%
\@ResetGT%
\edef\@currentlabel{\csname p@tabrefnote\endcsname\@thetabrefmark}%
\tabrefnoteformat}%
\def\@endantabrefnote{\endgroup}%
\tabrefnoteheading %
\tabrefnotesize%
\input{\jobname.tabref}%
\setcounter{tabrefnote}{0} %
\setcounter{tabrows}{0} %
\setcounter{tabcols}{0} %
\endgroup}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%
tabrefnotes.tex
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx,longtable,tabrefnote}
\usepackage{xcolor}
\parindent=0pt
\begin{document}
\section{Dummy}
Ein Text vor dem Problem.
\section{longtable}
\begin{longtable}[l]{p{2cm}p{2cm}p{2cm}}\caption{First}\\
Zähler&Nenner&Bruch\trfl
1\tabrefnote{null}&2&$\frac{1}{2}$\trfl
1\tabrefnote{Atest}&2\tabrefnote{Btest}&$\frac{1}{2}$\tabrefnote{Ctest}\trfl
1\tabrefnote{Dtest}&2\tabrefnote{Etest}&$\frac{1}{2}$\tabrefnote{Ftest}\trfl
1&2&$\frac{1}{2}$\trfl
\thetabrefnotes[]
\end{longtable}
\begin{longtable}[l]{p{2cm}p{2cm}p{2cm}}\caption{First}\\
Zähler&Nenner&Bruch\trfl
1\tabrefnote{null}&2&$\frac{1}{2}$\trfl
1\tabrefnote{Atest}&2\tabrefnote{Btest}&$\frac{1}{2}$\tabrefnote{Ctest}\trfl
1\tabrefnote{Dtest}&2\tabrefnote{Etest}&$\frac{1}{2}$\tabrefnote{Ftest}\trfl
1&2&$\frac{1}{2}$\trfl
\thetabrefnotes[]
\end{longtable}
\section{Dummy}
Ein Text \test nach dem Problem.
\end{document}