Referência em números de linha em tabelas

Referência em números de linha em tabelas

Um aluno meu precisa trabalhar em entrevistas. Ela tem respostas de vários entrevistados, que serão impressas como citação completa. Seu trabalho é analisar as respostas e fazer uma espécie de resumo. Portanto, as respostas devem receber números de linha, nos quais ela possa fazer referência.

Tentei habilitar package lineno, mas não consegui, fazer o label funcionar dentro de uma tabular.

Como você pode ver, consegui imprimir os números das linhas nas respostas citadas e desligá-los para análise.

MWE atualizado para mostrar várias linhas de texto digitado na tabela

\documentclass[%
   a4paper,
   11pt,
   twoside,
   parskip=half,
   english,
]{scrartcl}

%%% ------------------------------------------------------ &Packages ---
\usepackage{babel}                      % Language selection
\usepackage[T1]{fontenc}                % Output font encoding
\usepackage[newcommands]{ragged2e}      % Hyphenation in ragged modes
\usepackage[running]{lineno}            % Package for line numbers
\usepackage{array}                      % Improved tabular macros
\usepackage{xltabular}                  % X-Column and longtables altogether 
\usepackage{booktabs}                   % Nicer table lines

  

%%% --------------------------------------------------- &Definitions ---
%%% Some useful definitions . . .

%% Neuer Spaltentyp L für linksbündigen Flattersatz mit variabler
%% Breite (#1).  
\newcolumntype{L}[1]{ >{\nolinenumbers\raggedright\hspace{0pt}\arraybackslash} p{#1} }

%% Und noch mal, aber auf Basis der X-Spalte
\newcolumntype{Y}{
  >{\internallinenumbers\raggedright\hspace{0pt}\arraybackslash}
  X
  <{\nolinenumbers}
}

%% Und eine Definition für die Spaltenüberschriften
\newcolumntype{H}{ >{\footnotesize} c }


%% Neues Makro mit dem die Antwort eingegeben wird.
\newcommand{\answer}[1]{%
    \begin{linenumbers}%
      % \begin{numquote}%
      #1%
      % \end{numquote}%
    \end{linenumbers}%
}

%% Und zwei Befehle, um die referenzierte Zeilennummer zu markieren
%% bzw. zu referenzieren.
\newcommand{\imark}[1]{\linelabel{answer:#1}}
\newcommand{\iref}[1]{line~\ref{answer:#1}}
\newcommand{\iregion}[2]{%
  Zeilen~\ref{answer:#1}--\ref{answer:#2}%
}




%%% ====================================================== &Document ===
\begin{document}

%% This works
\begin{linenumbers}
  The sun\imark{sun} was shining the whole day.
\end{linenumbers}
In \iref{sun} she speaks of weather.

%% This works also
\answer{The sun didn't shine for month.  It was dark\imark{dark} and
  cold.}
In \iref{dark} temperatures are mentioned.

\begin{tabularx}{\linewidth}{@{} Y L{.3\textwidth} @{}}
  \toprule
  \multicolumn{1}{@{} H}{Answer}
  & \multicolumn{1}{H @{}}{Explanation} \\
  \midrule
  %% Numbers printed, reference undefined, no error messages
  \answer{The sun\imark{sun2} was shining the whole day.  
  But from time\iref{time} to time, it also rained, which poduced 
  beautiful rainbows\ilabel{rainbow} in the otherwise clear blue
  sky.\ilabel{sky}}
  & In \iref{sun2} she speaks of weather.\newline
    In \iregion{time}{sky} something other is discussed.\\
  % %% Error message: "\linelabel without \linenumbers".
  % The sun\imark{sun3} was shining the whole day.
  % & In \iref{sun3} she speaks of weather.\\
  \bottomrule
\end{tabularx}

\end{document}

Qual é o truque para armazenar/recuperar os números das linhas dentro da tabela?

Responder1

Que tal um truque sujo com paracol?

\documentclass[%
   a4paper,
   11pt,
   twoside,
   parskip=half,
   english,
]{scrartcl}
\usepackage{showframe}
%%% ------------------------------------------------------ &Packages ---
\usepackage{babel}                      % Language selection
\usepackage[T1]{fontenc}                % Output font encoding
\usepackage[newcommands]{ragged2e}      % Hyphenation in ragged modes
\usepackage[running]{lineno}            % Package for line numbers
\usepackage{array}                      % Improved tabular macros
\usepackage{xltabular}                  % X-Column and longtables altogether 
\usepackage{booktabs}                   % Nicer table lines
\usepackage{paracol}
\columnratio{0.7}
  

%%% --------------------------------------------------- &Definitions ---
%%% Some useful definitions . . .

%% Neuer Spaltentyp L für linksbündigen Flattersatz mit variabler
%% Breite (#1).  
\newcolumntype{L}[1]{ >{\nolinenumbers\raggedright\hspace{0pt}\arraybackslash} p{#1} }

%% Und noch mal, aber auf Basis der X-Spalte
\newcolumntype{Y}{
  >{\internallinenumbers\raggedright\hspace{0pt}\arraybackslash}
  X
  <{\nolinenumbers}
}

%% Und eine Definition für die Spaltenüberschriften
\newcolumntype{H}{ >{\footnotesize} c }


%% Neues Makro mit dem die Antwort eingegeben wird.
\newcommand{\answer}[1]{%
    \begin{linenumbers}%
      % \begin{numquote}%
      #1%
      % \end{numquote}%
    \end{linenumbers}%
}

%% Und zwei Befehle, um die referenzierte Zeilennummer zu markieren
%% bzw. zu referenzieren.
\newcommand{\imark}[1]{\linelabel{answer:#1}}
\newcommand{\iref}[1]{line~\ref{answer:#1}}
\newcommand{\iregion}[2]{%
  Zeilen~\ref{answer:#1}--\ref{answer:#2}%
}




%%% ====================================================== &Document ===
\begin{document}

%% This works
\begin{linenumbers}
  The sun\imark{sun} was shining the whole day.
\end{linenumbers}
In \iref{sun} she speaks of weather.

%% This works also
\answer{The sun didn't shine for month.  It was dark\imark{dark} and
  cold.}
In \iref{dark} temperatures are mentioned.

\begin{tabularx}{\linewidth}{@{}>{\footnotesize\centering\arraybackslash}p{.7\linewidth} >{\footnotesize\centering\arraybackslash}X@{}}
  \toprule
  Answer
  & Explanation \\
  \midrule
\end{tabularx}
\begin{sloppypar}
\begin{paracol}{2} 
  \answer{The sun\imark{sun2} was shining the whole day.  
  But from time\imark{time} to time, it also rained, which produced 
  beautiful rainbows\imark{rainbow} in the otherwise clear blue
  sky.\imark{sky}}
  \switchcolumn
  In sun: \iref{sun2} she speaks of weather.\newline
  Rainbows: \iref{rainbow}.\newline
  In time: \iref{time}, sky: \iref{sky} something other is discussed.
\end{paracol}
\begin{paracol}{2} 
  \answer{The sun\imark{sun3} was shining the whole day.  
  But from time\imark{time3} to time, it also rained, which produced 
  beautiful rainbows\imark{rainbow3} in the otherwise clear blue
  sky.\imark{sky3}}
  \switchcolumn
  In sun: \iref{sun3} she speaks of weather.\newline
  Rainbows: \iref{rainbow3}.\newline
  In time: \iref{time3}, sky: \iref{sky3} something other is discussed.
\end{paracol}
\end{sloppypar}\vspace{-8pt}
\begin{tabularx}{\linewidth}{@{}X@{}}
  \bottomrule
\end{tabularx}

\end{document}

insira a descrição da imagem aqui

informação relacionada