General ⇒ sections inside longtable: proper referencing
sections inside longtable: proper referencing
which contains sections and subsesctions (shown in multicolumns).
They are defined implicitly, e.g., not via \section, but via
\refstepcounter{section}\addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}
Each row in the table is a subsubsection. When I attempt to refer
to a row, I always get \thetable as a reference,
whereas I want \thesection\thesubsection.\thesubsubsection.
How do I redefine \label so that it would put the above sequence to the .aux file?
Spent lots of time searching, cannot find any clue.
Any other approaches?
In relation to that, is it possible to print definition of arbitrary LaTeX
command which is defined as a macro? It would be very convenient
for the purpose of redefining things...
Thanks,
Alex
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: sections inside longtable: proper referencing
Regarding your second question: \meaning\foo expands to the definition of \foo, whereas \show\foo prints the definition of \foo on the terminal.
sections inside longtable: proper referencing
whereas I want \ref to print 1.1.1 and 2.2.1
Thanks,
Alex
Code: Select all
\documentclass{report}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{ifthen}
\setcounter{tocdepth}{3}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
\newcommand{\padding}{7pt}
\newcommand{\entry}[4]{
\refstepcounter{subsubsection}
\parbox{13mm}{\vspace*{\padding}\centering \ifthenelse{\equal{\thesection}{0}}{}{\thesubsubsection} \vspace*{\padding}} &
\parbox{25mm}{\vspace*{\padding}\raggedright #1 \vspace*{\padding}} &
\parbox{10mm}{\vspace*{\padding}\centering #2 \vspace*{\padding}} &
\parbox{30mm}{\vspace*{\padding}\raggedright #3 \vspace*{\padding}} &
\parbox{40mm}{\vspace*{\padding}\raggedright #4 \vspace*{\padding}} \\ \hline
}
\newcommand{\sect}[1]{
\hline\multicolumn{5}{|c|}{
\refstepcounter{section}
\addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}
\parbox{128mm}{
\vspace*{\padding}\centering\large\bf \thesection. #1 \vspace*{\padding}
}
}\\ \hline
}
\newcommand{\subsect}[1]{
\hline\multicolumn{5}{|c|}{
\refstepcounter{subsection}
\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}
\parbox{128mm}{
\vspace*{\padding}\centering \thesubsection. #1 \vspace*{\padding}
}
}\\ \hline
}
\begin{document}
\tableofcontents
\begin{longtable}{|l|l|l|l|l|}
\hline\hline
\entry{\bf c1}{\bf c2}{\bf c3}{\bf c4}
\hline\hline
\endhead
\sect{Section 1}
\subsect{Subsection 1}
\entry{a}{b}{\label{l1} c}{d}
\entry{e}{f}{\ref{l1} g}{h}
\sect{Section 2}
\subsect{Subsection 1}
\subsect{Subsection 2}
\entry{m}{n}{\label{l2} o}{p}
\entry{i}{j}{\ref{l2} k}{l}
\end{longtable}
\end{document}
sections inside longtable: proper referencing
Code: Select all
\makeatletter
\newcommand{\entry}[4]{
\stepcounter{subsubsection}\global\let\old@currentlabel\@currentlabel\xdef\@currentlabel{\thesubsubsection}%
\parbox{13mm}{\vspace*{\padding}\centering \ifthenelse{\equal{\thesection}{0}}{}{\thesubsubsection} \vspace*{\padding}} &
\parbox{25mm}{\vspace*{\padding}\raggedright #1 \vspace*{\padding}} &
\parbox{10mm}{\vspace*{\padding}\centering #2 \vspace*{\padding}} &
\parbox{30mm}{\vspace*{\padding}\raggedright #3 \vspace*{\padding}} &
\parbox{40mm}{\vspace*{\padding}\raggedright #4 \vspace*{\padding}} \global\let\@currentlabel\old@currentlabel \\ \hline
}
\makeatother