1

I need to reference in table cell to another cell in another table. In both cells should be exhibited a number - the same number (once as a plain text inserted by me and once as a cross reference).

I tried the following, but in the output the reference doesn't show the number I set (i.e. '1' in the firs cell of the second table), but the chapter the table is in (i.e. '1.1' in the first cell of the first table).

\documentclass[11pt]{book}
\usepackage[english]{babel}
\usepackage{longtable}
\usepackage{setspace}

\begin{document}

\begin{small}
\begin{longtable}{ | p{0,8cm} | p{2,5cm} p{1,8cm} p{2,3cm} p{2,6cm}  | p{0,7cm} | }


  \caption{Coding frames for`ask (for)'}
  \label{table:Coding_frames_verb}
\endfirsthead
\hline
\textbf{\#} &   \textbf{Coding frame}&&& &  \textbf{f}\\
\hline
\ref{cf_1} & V.ACT.sbj[A] &[A]-NOM&[AD]-ACC & &11 \\
 \hline
2 & V.ACT.sbj[A] &[A]-NOM&[AD/T]-ACC && 1\\
\hline
\end{longtable}
\end{small}

\chapter{example of chapter}


\begin{small}
\begin{longtable}{ | p{0,3cm}  p{2,4cm} p{1,5cm} p{2,4cm}  p{0,5cm}   p{4cm} | }
\hline
\textbf{\#} & \textbf{Coding frame} &&& \textbf{f} &    \textbf{Passage in the Qur'an}\\ 

1\label{cf_1} & V.ACT.sbj[A] & [A]-NOM & [AD]-ACC & 11 &    2:108:4, 2:273:20,  7:6:5, 7:187:24, 9:65:2, 12:82:1, 16:43:9, 21:7:8, 23:113:7, 33:53:42, 55:29:1 \\ 

2&  V.ACT.sbj[A] & [A]-NOM & [AD/T]-ACC  &1 &   70:10:2 \\
3&V.ACT.sbj[A] & [A]-NOM & [UTT/T]-ACC& 1&  5:102:2\\

4&  V.ACT.sbj[A]&  [A]-NOM & [REQ]INDF.PRO &    1&  2:61:36\\
\hline
\end{longtable}
\end{small}
\end{document}

I would appreciate any suggestion!

1
  • Please try to minimize your example. All this longtable and small an so on is just adding noise to your question. Better show us two minimal tables and then a second example which shows the desired output (hard coded) you would like to see.
    – LaRiFaRi
    May 3, 2016 at 11:56

1 Answer 1

1

Something like this?

% arara: pdflatex
% arara: pdflatex

\documentclass[11pt]{book}
\usepackage{longtable}
\usepackage{array} % take a look on the corners of your tables. 
\usepackage{hyperref}

\begin{document}    
\begin{small}
    \begin{longtable}{ | p{0,8cm} | p{2,5cm} p{1,8cm} p{2,3cm} p{2,6cm}  | p{0,7cm} | }         
        \caption{Coding frames for`ask (for)'}\label{table:Coding_frames_verb}
        \endfirsthead
        \hline
        \textbf{\#} &   \textbf{Coding frame}&&& &  \textbf{f}\\
        \hline
        \hyperref[cf_1]{1} & V.ACT.sbj[A] &[A]-NOM&[AD]-ACC & &11 \\
        \hline
        2 & V.ACT.sbj[A] &[A]-NOM&[AD/T]-ACC && 1\\
        \hline
    \end{longtable}
\end{small}
\chapter{example of chapter}    
\begin{small}
    \begin{longtable}{ | p{0,3cm}  p{2,4cm} p{1,5cm} p{2,4cm}  p{0,5cm}   p{4cm} | }
        \hline
        \textbf{\#} & \textbf{Coding frame} &&& \textbf{f} &    \textbf{Passage in the Qur'an}\\ 
        1\label{cf_1} & V.ACT.sbj[A] & [A]-NOM & [AD]-ACC & 11 &    2:108:4, 2:273:20,  7:6:5, 7:187:24, 9:65:2, 12:82:1, 16:43:9, 21:7:8, 23:113:7, 33:53:42, 55:29:1 \\ 
        2&  V.ACT.sbj[A] & [A]-NOM & [AD/T]-ACC  &1 &   70:10:2 \\
        3&V.ACT.sbj[A] & [A]-NOM & [UTT/T]-ACC& 1&  5:102:2\\
        4&  V.ACT.sbj[A]&  [A]-NOM & [REQ]INDF.PRO &    1&  2:61:36\\
        \hline
    \end{longtable}
\end{small}
\end{document}

Please add \usepackage{showframe} to your preamble. It will show you that both tables are too wide. Why don't you use l columns instead?

5
  • thank you! Exactly like this! And what do you mean by '1 columns'?
    – csilla
    May 3, 2016 at 12:12
  • @csilla you are welcome. Not 1, l. Left aligned columns. E.g. \begin{longtable}{|l|*{4}{l}|l|} . Just try them, it will look much better. And you safe a lot of hard coded column width definitions. If you want to set any table width by hand, you could stick to Word :-)
    – LaRiFaRi
    May 3, 2016 at 12:14
  • ok, I shall try. You are right! I'm a beginner so I am grateful for any improvement!
    – csilla
    May 3, 2016 at 12:19
  • @csilla The second table could be \begin{longtable}{|lllll>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{3.9cm}|} and maybe you set "Coding frame" in a \multicolumn{2}{l}{\textbf{Coding frame}}
    – LaRiFaRi
    May 3, 2016 at 12:24
  • I tried your first suggestion. My table in my real document is a lot longer and the columns in the other rows are far wider, so your suggestion works only for the rows that have a similar with. And I shall try your other code as well - the other table is not so big. Thanks again!
    – csilla
    May 3, 2016 at 12:30

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.