1

I'm making an interview. I have a table with "Questions and Explanations" and a table with "Questions and Answers". I have labeled each row, so I can reference each question later on. I would like to change the labeling, and also reference my Questions and Answers table different for each interview person: I would like to number and label each row in my table so I can reference them later on.

I get the following output: enter image description here enter image description here

I would like the output to look like this: enter image description here enter image description here

Please help Thank you

My code is:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[danish]{babel}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color} 
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{float} 
\usepackage[top=2.81cm, bottom=2.75cm,right=2cm, left=2cm]{geometry}
\usepackage{url}
\usepackage[hidelinks]{hyperref}
\hypersetup{breaklinks=true}
\usepackage{setspace}
   \onehalfspacing
   \usepackage[T1]{fontenc}

%%% DETTE ER NUMERERING AF RÆKKER I TABELLER
\usepackage{etoolbox}
\usepackage{setspace}
\onehalfspacing
\usepackage{url}
\usepackage[hidelinks]{hyperref}
\hypersetup{breaklinks=true}
\newcounter{rowcntr}[table]
\makeatletter
% Assuming arabic numbers for the table number -- in case of bottom table caption, we have to increase the table number by one, only for output. 
\usepackage{longtable}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{V}[1]{>{\raggedright\let\newline\\\arraybackslash}p{\dimexpr#1-2\tabcolsep-\arrayrulewidth}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\renewcommand{\therowcntr}{\@arabic{\numexpr\c@table+1}.\arabic{rowcntr}}
\makeatother
\newcolumntype{N}{>{\refstepcounter{rowcntr}\therowcntr}c}
\AtBeginEnvironment{tabular}{\setcounter{rowcntr}{0}}
%%% DETTE ER NUMERERING AF RÆKKER I TABELLER
\begin{document}
\section*{Interview questions}
The following table contains my interview questions and explanation

\begin{center}
    \begin{longtable}{|N| c | V{7.6cm} | V{7.6cm} |}
    \hline
    \multicolumn{2}{|c}{} & \multicolumn{1}{c|}{\textbf{Question}} & \multicolumn{1}{c|}{\textbf{Explanation}} \\ \hline
   \multicolumn{4}{|c|}{Interview phase 1}\\ \hline
   \multicolumn{4}{|C{17.5cm}|}{\textit{Text This phase focus on ...TextTextTextTextText TextTextTextTextTextTextTextTextTextTextText TextText TextTextText TextTextTextTextTextTextTextTextTextText Text Text Text Text Text Text Text Text }}\\ \hline
   \label{que:1} & A & Do you think ...? & This is a good question.\\
   \label{que:2} & C & Do you feel Text & This is a good question.\\
   \label{que:3} & E & What do you think of your previous boss & Relationship between employee and employer text Text textText text Text text Text text.\\ \hline
   \multicolumn{4}{|c|}{Interview phase 2}\\ \hline
   \multicolumn{4}{|C{17.5cm}|}{\textit{Text This phase focus on ... }}\\ \hline
   \label{que:4} & D & Is this ...? & Good question.\\
   \label{que:5} & I & Do you like Text  & A good question.\\
   \label{que:6} & A & what do you think of your mother & Relationship \\ \hline

   \caption {Questions and explanation} \label{tab:interviewspg}
    \end{longtable}
\end{center}
\section*{Interview answers person A}
The following section contains the answers from interviewperson A
\begin{center}
    \begin{longtable}{|N|  V{8.3cm} | V{8.3cm} |}
    \hline
    \multicolumn{1}{|c}{} & \multicolumn{1}{c|}{\textbf{Question}} & \multicolumn{1}{c|}{\textbf{Answer}} \\ \hline
   \label{QA:1} &  Do you think ...? & Yes I think.\\
   \label{QA:2} &  Do you feel Text & I feel a lot of text.\\
   \label{QA:3} & What do you think of your previous boss & I hated him.\\
   \label{QA:3a} & \textbf{This is an unexpected follow up question} \textbf{Why did you hate him?} & \textbf{Because he was evil.}\\
   \label{QA:4} &  Is this ...? & Yes\\
   \label{QA:5} & Do you like Text  & Text is good.\\
   \label{QA6:6} & what do you think of your mother & I really like my mother \\ \hline

   \caption {Questions and answers} \label{tab:interviewspg}
    \end{longtable}
\end{center}

\newpage
\section*{Interview answers person B}
The following section contains the answers from interviewperson B
\begin{center}
    \begin{longtable}{|N|  V{8.3cm} | V{8.3cm} |}
    \hline
    \multicolumn{1}{|c}{} & \multicolumn{1}{c|}{\textbf{Question}} & \multicolumn{1}{c|}{\textbf{Answer}} \\ \hline
   \label{QB:1} &  Do you think ...? & No\\
   \label{QB:2} &  Do you feel Text & No you can't feel text\\
   \label{QB:3} & What do you think of your previous boss & She was okay\\
   \label{QB:4} &  Is this ...? & No\\
   \label{QB:5} & Do you like Text  & Text is bad.\\
   \label{QA6:6} & what do you think of your mother & I would like to not answer that \\ \hline

   \caption {Questions and answers} \label{tab:interviewspg}
    \end{longtable}
\end{center}
\end{document}
  • As I can see you you have used code from my answer to your other question ;-) This is possible, of course, but the usual approach is to give at least some indication who wrote the originals of this (regardless who it is) – user31729 Mar 10 '17 at 20:27
  • How can I indicate that you (or someone else) wrote the original code? :-) – Jonas Mar 10 '17 at 23:09
2

Here's an approach with a separate interviewee counter and a \subquest command to change temporarily the row counter format and providing a correct label for this.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[danish]{babel}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color} 
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{float} 
\usepackage[top=2.81cm, bottom=2.75cm,right=2cm, left=2cm]{geometry}
\usepackage{setspace}
   \onehalfspacing
   \usepackage[T1]{fontenc}

%%% DETTE ER NUMERERING AF RÆKKER I TABELLER
\usepackage{etoolbox}
\usepackage{setspace}
\onehalfspacing
\usepackage{url}
\usepackage[hidelinks]{hyperref}
\hypersetup{breaklinks=true}
\newcounter{rowcntr}

\newcounter{interviewee}
\newcounter{subquestion}

\renewcommand{\theinterviewee}{\Alph{interviewee}}

% This is meant for a subquestion
\newcommand{\subquest}{%
  \stepcounter{subquestion}% 
  \addtocounter{rowcntr}{-1}%
  \let\origtherowcntr\therowcntr%
  \renewcommand{\therowcntr}{\origtherowcntr.\alph{subquestion}}%
  \refstepcounter{rowcntr}%
}

\makeatletter
\newcommand{\prepareresultsections}{%
  \setcounter{rowcntr}{0}
  \@addtoreset{rowcntr}{table}
  % Change the rowcntr format for the interview results
  \renewcommand{\therowcntr}{\theinterviewee.\arabic{rowcntr}}
}
\makeatother



\newcommand{\resultsection}[1]{%
  \clearpage
  \refstepcounter{interviewee}%
  \section*{#1}%
}

\makeatletter
% Assuming arabic numbers for the table number -- in case of bottom table caption, we have to increase the table number by one, only for output. 
\usepackage{longtable}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{V}[1]{>{\raggedright\let\newline\\\arraybackslash}p{\dimexpr#1-2\tabcolsep-\arrayrulewidth}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
%\renewcommand{\therowcntr}{\@arabic{\numexpr\c@table+1}.\arabic{rowcntr}}
\makeatother
\newcolumntype{N}{>{\refstepcounter{rowcntr}\therowcntr}c}
\AtBeginEnvironment{tabular}{\setcounter{rowcntr}{0}\setcounter{subquestion}{0}}
%%% DETTE ER NUMERERING AF RÆKKER I TABELLER
\begin{document}


\section*{Interview questions}
The following table contains my interview questions and explanation

\begin{center}
    \begin{longtable}{|N| c | V{7.6cm} | V{7.6cm} |}
    \hline
    \multicolumn{2}{|c}{} & \multicolumn{1}{c|}{\textbf{Question}} & \multicolumn{1}{c|}{\textbf{Explanation}} \\ \hline
   \multicolumn{4}{|c|}{Interview phase 1}\\ \hline
   \multicolumn{4}{|C{17.5cm}|}{\textit{Text This phase focus on ...TextTextTextTextText TextTextTextTextTextTextTextTextTextTextText TextText TextTextText TextTextTextTextTextTextTextTextTextText Text Text Text Text Text Text Text Text }}\\ \hline
   \label{que:1} & A & Do you think ...? & This is a good question.\\
   \label{que:2} & C & Do you feel Text & This is a good question.\\
   \label{que:3} & E & What do you think of your previous boss & Relationship between employee and employer text Text textText text Text text Text text.\\ \hline
   \multicolumn{4}{|c|}{Interview phase 2}\\ \hline
   \multicolumn{4}{|C{17.5cm}|}{\textit{Text This phase focus on ... }}\\ \hline
   \label{que:4} & D & Is this ...? & Good question.\\
   \label{que:5} & I & Do you like Text  & A good question.\\
   \label{que:6} & A & what do you think of your mother & Relationship \\ \hline

   \caption {Questions and explanation} \label{tab:interviewspg}
    \end{longtable}
\end{center}


\prepareresultsections
\resultsection{Interview answers person \theinterviewee}
The following section contains the answers from interviewperson \theinterviewee
\begin{center}
    \begin{longtable}{|N|  V{8.3cm} | V{8.3cm} |}
    \hline
    \multicolumn{1}{|c}{} & \multicolumn{1}{c|}{\textbf{Question}} & \multicolumn{1}{c|}{\textbf{Answer}} \\ \hline
   \label{QA:1} &  Do you think ...? & Yes I think.\\
   \label{QA:2} &  Do you feel Text & I feel a lot of text.\\
   \label{QA:3} & What do you think of your previous boss & I hated him.\\
   \multicolumn{1}{|c|}{\subquest\therowcntr\label{QA:3a}} & \textbf{This is an unexpected follow up question} \textbf{Why did you hate him?} & \textbf{Because he was evil.}\\
   \label{QA:4} &  Is this ...? & Yes\\
   \label{QA:5} & Do you like Text  & Text is good.\\
   \label{QA6:6} & what do you think of your mother & I really like my mother \\ \hline

   \caption {Questions and answers} \label{tab:interviewspgA}
    \end{longtable}
\end{center}





\resultsection{Interview answers person \theinterviewee}
The following section contains the answers from interviewperson \theinterviewee

\begin{center}
    \begin{longtable}{|N|  V{8.3cm} | V{8.3cm} |}
    \hline
    \multicolumn{1}{|c}{} & \multicolumn{1}{c|}{\textbf{Question}} & \multicolumn{1}{c|}{\textbf{Answer}} \\ \hline
   \label{QB:1} &  Do you think ...? & No\\
   \label{QB:2} &  Do you feel Text & No you can't feel text\\
   \label{QB:3} & What do you think of your previous boss & She was okay\\
   \label{QB:4} &  Is this ...? & No\\
   \label{QB:5} & Do you like Text  & Text is bad.\\
   \label{QB:6} & what do you think of your mother & I would like to not answer that \\ \hline

   \caption {Questions and answers} \label{tab:interviewspgB}
    \end{longtable}
\end{center}
\end{document}

Better approaches need more information and more thorough design,as it stands, the desired features are not clearly stated.

enter image description here

  • You are amazing! Thank you! I have 2 questions: 1) Is it possible to have a N command which can label table rows "Table number.rownumber" ex 1.1,1.2,1.3 like this one: \renewcommand{\therowcntr}{\@arabic{\numexpr\c@table+1}.\arabic{rowcntr}} \makeatother \newcolumntype{N}{>{\refstepcounter{rowcntr}\therowcntr}c} \AtBeginEnvironment{tabular}{\setcounter{rowcntr}{0}} And the new one which can label table rows "rownumber" ex 1,2,3,4 like: – Jonas Mar 10 '17 at 22:18
  • I will look tomorrow, for now it is too late for me ;-) – user31729 Mar 10 '17 at 22:30
  • Okay thank you :-) The second question is: 2) Is it possible to also make a table with 3 columns where the 1. column contains label with "Question 1 Person A "= QA1 in row 1 and "Answer 1 Person A"=AA1 in row 2. Like this: QA1 & Question 1 person A\\ AA1 & Answer 1 person A\\ QA2 & Question 2 person A\\ AA2 & Answer 1 person A\\ QA2.a & Unexpected Question person A\\ AA2.a & Unexpected answer person A\\ Same principle with person B and C Thank you – Jonas Mar 10 '17 at 22:51
  • @Jonas: Actually, I think you're requesting things which weren't in your question and I don't like changed questions which lead to a state which leaves the current effort useless. The whole tabular approach etc. isn't well designed yet and repairing one thing at one end removes something at the other end. – user31729 Mar 11 '17 at 12:16
  • @ Christian I'm sorry. I was just looking at different options :-) Let me try to clarify the intention of this post: I am conducting a series of interviews with person A,B,C,D ect. I have prepared an "interview model", with question I'm going to ask (Every question is labeled with 1,2,3,4) (Table questions and explanations) Lets say I interview person A, every question I ask person A will be labeled A.1,A,2,A3 ect. "A" corresponds to interview person A and "1" corresponds to question 1 in the "interviewmodel". Lets say I ask a follow up question (which is not in the "Interviewmodel") ... – Jonas Mar 11 '17 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.