PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Verweis auf Tabelle im Anhang mit \ref und \label



pandabier
30-04-2013, 14:53
Hallo,

ich möchte im Hauptteil meiner Arbeit auf eine Tabelle im Anhang referenzieren und im Text gern "Table 1" stehen haben. Leider wird statt der Nummer der Tabelle der Abschnitt, in dem die Tabelle steht, ausgegeben. Füge ich die Tabelle im Hauptteil (also nicht im Anhang) ein, funktioniert das Referenzieren ohne Probleme. Hat jemand eine Idee?

Viele Grüße
pandabier


\documentclass[fleqn]{article}
\usepackage[nochapters,beramono,eulermath]{classicthesis}
\usepackage[ngerman,american]{babel}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{threeparttablex}


\begin{document}

\section{section 1}
Table \ref{tab:fx} ...

\appendix
\section{appendix}
\subsection{appendix subsection}
\begin{ThreePartTable}
\begin{longtabu}{@{}llXXXXX}
\caption{...}\\
\toprule
\textbf{} & & \textbf{1999 --2000} & \textbf{2001} & \textbf{2002 --2008} & \textbf{2009 --2011} & \textbf{country} \\
\midrule
\endfirsthead
\endhead
\endfoot
...
\end{longtabu}
\label{tab:fx}
\end{ThreePartTable}

\end{document}

esdd
30-04-2013, 18:04
Hallo,
der \label Befehl steht bei dir außerhalb der longtabu Umgebung und verweist deshalb auf den Abschnitt. Daran ändert sich auch nichts, wenn man \appendix auskommentiert.
Setz das \label innerhalb von longtabu, zum Beispiel bei \caption im firsthead.
Gruß
Elke

pandabier
30-04-2013, 18:30
Vielen Dank! Das hat schon einmal sehr geholfen. Ich habe den Code angepasst und noch ergänzt, dass die Tabellen im Appendix wieder bei 1 anfangen zu zählen. Wenn ich jetzt auf die Referenz im ersten Abschnitt klicke, werde ich zu Tabelle 1 geleitet und nicht zur ersten Tabelle im Anhang. Wie kann ich das Problem lösen?


\documentclass[fleqn]{article}
\usepackage[nochapters,beramono,eulermath]{classicthesis}
\usepackage[ngerman,american]{babel}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{threeparttablex}


\begin{document}

\section{section 1}
Table \ref{tab:fx} ...

\begin{ThreePartTable}
\begin{longtabu}{@{}llXXXXX}

\caption{...} \label{tab:test}\\
\toprule
\textbf{} & & \textbf{1999 --2000} & \textbf{2001} & \textbf{2002 --2008} & \textbf{2009 --2011} & \textbf{country} \\
\midrule
\endfirsthead
\endhead
\endfoot
...
\end{longtabu}
\end{ThreePartTable}

\renewcommand{\thetable}{\Alph{section}.\arabic{ta ble}}
\setcounter{table}{0}

\appendix
\section{appendix}
\subsection{appendix subsection}
\begin{ThreePartTable}
\begin{longtabu}{@{}llXXXXX}

\caption{...} \label{tab:fx}\\
\toprule
\textbf{} & & \textbf{1999 --2000} & \textbf{2001} & \textbf{2002 --2008} & \textbf{2009 --2011} & \textbf{country} \\
\midrule
\endfirsthead
\endhead
\endfoot
...
\end{longtabu}
\end{ThreePartTable}

\end{document}

esdd
30-04-2013, 20:31
Hallo,

einfach den Zähler zurückzusetzen ist keine gute Idee. Du müsstest auch eine Warnung bezüglich same identifier bekommen.
Du kannst das Paket chngcntr nutzen.


...
\usepackage{chngcntr}
...
\appendix
\counterwithin{table}{section}
\section{appendix}
...


Gruß
Elke

pandabier
02-05-2013, 11:46
Vielen Dank für die Hilfe, Elke! Hat mir sehr geholfen und funktioniert jetzt bestens :)

pandabier
22-10-2014, 11:18
Hallo nochmal nach langer Zeit,

ich habe in der Zwischenzeit mein Dokument erweitert und die Struktur sieht ungefähr so aus:

Chapter
Section
Subsection
Section
Subsection
Appendix A
Appendix B

Chapter
Section
Section
Subsection
Section
Appendix A

...

Bei der Nummerierung der Tabellen gibt es leider Probleme. Die Tabellen sollen im Anhang innerhalb des Anhangs (section) gezählt werden, anschließend aber wieder für das gesamte Kapitel (chapter). Mir gelingt es aber nicht, dies wieder zurückzuändern. Wie kann man das machen?

Konkret soll gezählt werden:
Table 1.1, 1.2, 1.3
Table 1.A.1, 1.A.2, 1.B.1, 1.B.2

Table 2.1, 2.2, 2.3, 2.4, 2.5 [funktioniert mit meinem code nicht]
Table 2.A.1, 2.A.2, 2.B.1

Falls \setcounter{section}{0} ein Problem darstellen sollte. Musste ich leider benutzen, siehe http://www.mrunix.de/forums/showthread.php?75964-pdfbookmark-amp-setcounter


Wäre super dankbar für Hilfe! Ich probiere schon ewig rum.
Liebe Grüße!



\documentclass[10pt,a4paper,floatperchapter]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,american]{babel}
\usepackage{classicthesis}

\PassOptionsToPackage{printonlyused,smaller}{acron ym}
\usepackage{acronym} % nice macros for handling all acronyms in the thesis
\usepackage{chngcntr} %Tabellen im Anhang sollen bei 1 beginnend neu durchnummeriert sein
%groups tables/figures of a chapter by adding additional space between entries of a different chapter in list of tables/figures
\usepackage{etoolbox}
\newcommand{\killdeactivateaddvspace}{\let\deactiv ateaddvspace\relax}
\AtEndPreamble{\addtocontents{lot}{\protect\killde activateaddvspace}\addtocontents{lof}{\protect\kil ldeactivateaddvspace}}

%neue Umgebung, damit die pdfbookmarks bei Appendix-Sections pro Kapitel noch stimmen
\newenvironment{secapp}{%
\renewcommand{\thesection}{\thechapter.\Alph{secti on}}%
\renewcommand{\theHsection}{\theHchapter.\Alph{sec tion}}%
\setcounter{section}{0}%
\counterwithin{table}{section} %Tabellen und Abb. sollen mit "A.1" etc. nummeriert sein (beginnend bei 1)
\counterwithin{figure}{section}
}{}

\begin{document}
\pagenumbering{roman}
\pagestyle{plain}
\listoftables
\tableofcontents

\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Section}
\subsection{Subsection}
\begin{table}\caption{Tabelle}\end{table}
\begin{secapp}
\counterwithin{table}{section} %Tabellen und Abb. sollen mit "A.1" etc. nummeriert sein (beginnend bei 1)
\counterwithin{figure}{section}
\section{Appendix: A}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Appendix: B}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\end{secapp}

\counterwithin{table}{chapter} %zu ursprünglicher Zählweise zurückkehren -- funktioniert so aber nicht
\counterwithin{figure}{chapter}
\renewcommand{\thesection}{\arabic{chapter}.\arabi c{section}}
\cleardoublepage % use here to avoid problems with pdfbookmark
\chapter{Chapter}
\section{Section}
\begin{table}\caption{Tabelle}\end{table}
\section{Section}
\subsection{Control variables}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Section}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\begin{secapp}
\section{Appendix: A}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Appendix: B}
\begin{table}\caption{Tabelle}\end{table}
\end{secapp}

\end{document}

ctansearch
23-10-2014, 01:44
Siehe Antwort unten vom 23-10-2014, 23:43

klops
23-10-2014, 07:59
Ich glaube, Du machst einen großen Fehler, wenn Du \thesection umdefinierst. \thesection ist ein Wert
Nein. \value{section} ist ein Wert. \thesection ist die Ausgabe eines Werts und die muss sogar Befehle wie \Alph, \arabic o. ä. enthalten und enthält auch ganz normal Befehle wie \thechapter und ggf. Punkte oder Klammern. Das hat auch nichts damit zu tun, ob man KOMA-Script verwendet. Das ist schon bei den Standardklassen so. Das grundsätzliche Vorgehen von pandabier ist also durchaus richtig.

@pandabier: Leider hast Du Deinen Code nicht als Code, sondern als Quote formatiert. Daher wird er (zumindest bei mir) mit einigen falschen Leerzeichen versehen und kann nicht einfach kopiert werden. Ich kann ihn deshalb leider auch nicht direkt testen. Ich muss erst sehen, ob ich Zeit finde, ihn nach dem Kopieren wieder lauffähig zu bekommen. Vielleicht kannst Du einfach Deinen Beitrag bearbeiten, um die Formatierung mit Code-Tags statt Quote-Tags zu machen. Das würde den Helfern die Arbeit erleichtern.

ctansearch
23-10-2014, 23:43
Ich glaube, so würde es gehen.
Bitte mal testen.



\documentclass[10pt,a4paper,floatperchapter]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,american]{babel}
\usepackage{classicthesis}
\PassOptionsToPackage{printonlyused,smaller}{acron ym}
\usepackage{acronym} % nice macros for handling all acronyms in the thesis
\usepackage{chngcntr} %Tabellen im Anhang sollen bei 1 beginnend neu durchnummeriert sein
%groups tables/figures of a chapter by adding additional space between entries of a different chapter in list of tables/figures
\usepackage{etoolbox}
\newcommand{\killdeactivateaddvspace}{\let\deactiv ateaddvspace\relax}
\AtEndPreamble{\addtocontents{lot}{\protect\killde activateaddvspace}\addtocontents{lof}{\protect\kil ldeactivateaddvspace}}
%neue Umgebung, damit die pdfbookmarks bei Appendix-Sections pro Kapitel noch
%stimmen
\newenvironment{secapp}{%
\setcounter{section}{0}
\counterwithin{table}{section} %Tabellen und Abb. sollen mit "A.1" etc. nummeriert sein (beginnend bei 1)
\counterwithin{figure}{section}
\renewcommand{\thesection}{\thechapter.\Alph{secti on}}%
%\newcommand{\theHsection}{\theHchapter.\Alph{sect ion}}%
}{
%NEUVON
\counterwithout{table}{section} %Tabellen und Abb. sollen mit "A.1" etc. nummeriert sein (beginnend bei 1)
\counterwithout{figure}{section}%
\counterwithin{table}{chapter} %Tabellen und Abb. sollen mit "A.1" etc. nummeriert sein (beginnend bei 1)
\counterwithin{figure}{chapter}

%NEUBIS
}%
\begin{document}
\pagenumbering{roman}
\pagestyle{plain}
\listoftables
\tableofcontents
\chapter{Kapitel 1}
\section{Section}
\subsection{Subsection}
\begin{table}\caption{Tabelle}%
\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Section}
\subsection{Subsection}
\begin{table}\caption{Tabelle}\end{table}
\begin{secapp}

\section{Appendix: A}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Appendix: B}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\end{secapp}

\cleardoublepage % use here to avoid problems with pdfbookmark
\chapter{Kapitel 1}
\section{Section}
\subsection{Subsection}
\begin{table}\caption{Tabelle}%
\end{table}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\section{Section}
\subsection{Subsection}
\begin{table}\caption{Tabelle}\end{table}
\begin{secapp}

\section{Appendix: A}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}

\section{Appendix: B}
\begin{table}\caption{Tabelle}\end{table}
\begin{table}\caption{Tabelle}\end{table}
\end{secapp}
\end{document}

pandabier
28-10-2014, 09:49
vielen lieben dank! funktioniert! sorry für das nicht-kompilierbare minimalbeispiel. werde in zukunft darauf achten, die richtige formatierungsumgebung hier im forum zu verwenden.