PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Bezifferung von Gnumeric Tabellen



smusecat
12-04-2007, 13:49
Ich habe versucht in Gnumeric erzeugte Tabellen in einer table Umgebung in mein Latex-Dokument einzufügen. Leider klappt das mit der Nummerierung nicht. Latex vergibt dabei nur ganzzahlige Nummern, es gibt also Tabelle 2, Tabelle 4, Tabelle 6 etc., aber keine Tabelle 1,Tabelle 3 etc.

\begin{table}
\centering
\caption{Übersicht }
\input{tabelle.tex}
\label{PCB}
\end{table}

Wenn ich das ganze ohne Gnumeric-Tabelle mache funktioniert es. Irgendeine Ahnung woran das liegen könnte? Danke

lupus68
12-04-2007, 18:23
ganz, gerade oder ganzgrade?

smusecat
12-04-2007, 20:54
ups, meinte natürlich geradzahlige Ziffern (2, 4, 6, 8, )

countbela666
13-04-2007, 06:50
Klingt, als würde in der tabelle.tex der table-counter ein weiteres Mal hochgezählt werden; ist aber -- wie so häufig -- ohne Minimalbeispiel nicht nachvollziehbar.

Grüße
Marcel

smusecat
13-04-2007, 10:35
Ok, hier also ein Beispiel

Meine von Gnumric erzeugte Tabelle (tabelle.tex) sieht so aus:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
%% %%
%% This is the header of a LaTeX2e file exported from Gnumeric. %%
%% %%
%% This file can be compiled as it stands or included in another %%
%% LaTeX document. The table is based on the longtable package so %%
%% the longtable options (headers, footers...) can be set in the %%
%% preamble section below (see PRAMBLE). %%
%% %%
%% To include the file in another, the following two lines must be %%
%% in the including file: %%
%% \def\inputGnumericTable{} %%
%% at the beginning of the file and: %%
%% \input{name-of-this-file.tex} %%
%% where the table is to be placed. Note also that the including %%
%% file must use the following packages for the table to be %%
%% rendered correctly: %%
%% \usepackage[latin1]{inputenc} %%
%% \usepackage{color} %%
%% \usepackage{array} %%
%% \usepackage{longtable} %%
%% \usepackage{calc} %%
%% \usepackage{multirow} %%
%% \usepackage{hhline} %%
%% \usepackage{ifthen} %%
%% optionally (for landscape tables embedded in another document): %%
%% \usepackage{lscape} %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%



%% This section checks if we are begin input into another file or %%
%% the file will be compiled alone. First use a macro taken from %%
%% the TeXbook ex 7.7 (suggestion of Han-Wen Nienhuys). %%
\def\ifundefined#1{\expandafter\ifx\csname#1\endcs name\relax}


%% Check for the \def token for inputed files. If it is not %%
%% defined, the file will be processed as a standalone and the %%
%% preamble will be used. %%
\ifundefined{inputGnumericTable}

%% We must be able to close or not the document at the end. %%
\def\gnumericTableEnd{\end{document}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
%% %%
%% This is the PREAMBLE. Change these values to get the right %%
%% paper size and other niceties. Uncomment the landscape option %%
%% to the documentclass defintion for standalone documents. %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%

\documentclass[12pt%
%,landscape%
]{report}
\usepackage[latin1]{inputenc}
\usepackage{fullpage}
\usepackage{color}
\usepackage{array}
\usepackage{longtable}
\usepackage{calc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{ifthen}

\begin{document}


%% End of the preamble for the standalone. The next section is for %%
%% documents which are included into other LaTeX2e files. %%
\else

%% We are not a stand alone document. For a regular table, we will %%
%% have no preamble and only define the closing to mean nothing. %%
\def\gnumericTableEnd{}

%% If we want landscape mode in an embedded document, comment out %%
%% the line above and uncomment the two below. The table will %%
%% begin on a new page and run in landscape mode. %%
% \def\gnumericTableEnd{\end{landscape}}
% \begin{landscape}


%% End of the else clause for this file being \input. %%
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
%% %%
%% The rest is the gnumeric table, except for the closing %%
%% statement. Changes below will alter the table's appearance. %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%

\providecommand{\gnumericmathit}[1]{#1}
%% Uncomment the next line if you would like your numbers to be in %%
%% italics if they are italizised in the gnumeric table. %%
%\renewcommand{\gnumericmathit}[1]{\mathit{#1}}
\providecommand{\gnumericPB}[1]%
{\let\gnumericTemp=\\#1\let\\=\gnumericTemp\hspace {0pt}}
\ifundefined{gnumericTableWidthDefined}
\newlength{\gnumericTableWidth}
\newlength{\gnumericTableWidthComplete}
\global\def\gnumericTableWidthDefined{}
\fi

%% The default table format retains the relative column widths of %%
%% gnumeric. They can easily be changed to c, r or l. In that case %%
%% you may want to comment out the next line and uncomment the one %%
%% thereafter %%
\providecommand\gnumbox{\makebox[0pt]}
%%\providecommand\gnumbox[1][]{\makebox}

%% to adjust positions in multirow situations %%
\setlength{\bigstrutjot}{\jot}
\setlength{\extrarowheight}{\doublerulesep}

%% The \setlongtables command keeps column widths the same across %%
%% pages. Simply comment out next line for varying column widths. %%
\setlongtables

\setlength\gnumericTableWidth{%
53pt+%
53pt+%
53pt+%
53pt+%
0pt}
\def\gumericNumCols{4}
\setlength\gnumericTableWidthComplete{\gnumericTab leWidth+%
\tabcolsep*\gumericNumCols*2+\arrayrulewidth*\gume ricNumCols}
\ifthenelse{\lengthtest{\gnumericTableWidthComplet e > \textwidth}}%
{\def\gnumericScale{\ratio{\textwidth-%
\tabcolsep*\gumericNumCols*2-%
\arrayrulewidth*\gumericNumCols}%
{\gnumericTableWidth}}}%
{\def\gnumericScale{1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
%% %%
%% The following are the widths of the various columns. We are %%
%% defining them here because then they are easier to change. %%
%% Depending on the cell formats we may use them more than once. %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%

\def\gnumericColA{53pt*\gnumericScale}
\def\gnumericColB{53pt*\gnumericScale}
\def\gnumericColC{53pt*\gnumericScale}
\def\gnumericColD{53pt*\gnumericScale}

\begin{longtable}[c]{%
b{\gnumericColA}%
b{\gnumericColB}%
b{\gnumericColC}%
b{\gnumericColD}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
%% The longtable options. (Caption, headers... see Goosens, p.124) %%
% \caption{The Table Caption.} \\ %
% \hline % Across the top of the table.
%% The rest of these options are table rows which are placed on %%
%% the first, last or every page. Use \multicolumn if you want. %%

%% Header for the first page. %%
% \multicolumn{4}{c}{The First Header} \\ \hline
% \multicolumn{1}{c}{colTag} %Column 1
% &\multicolumn{1}{c}{colTag} %Column 2
% &\multicolumn{1}{c}{colTag} %Column 3
% &\multicolumn{1}{c}{colTag} \\ \hline %Last column
% \endfirsthead

%% The running header definition. %%
% \hline
% \multicolumn{4}{l}{\ldots\small\slshape continued} \\ \hline
% \multicolumn{1}{c}{colTag} %Column 1
% &\multicolumn{1}{c}{colTag} %Column 2
% &\multicolumn{1}{c}{colTag} %Column 3
% &\multicolumn{1}{c}{colTag} \\ \hline %Last column
% \endhead

%% The running footer definition. %%
% \hline
% \multicolumn{4}{r}{\small\slshape continued\ldots} \\
% \endfoot

%% The ending footer definition. %%
% \multicolumn{4}{c}{That's all folks} \\ \hline
% \endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%

\gnumericPB{\raggedleft}\gnumbox[r]{1}
&\gnumericPB{\raggedleft}\gnumbox[r]{5}
&\gnumericPB{\raggedleft}\gnumbox[r]{9}
&\gnumericPB{\raggedleft}\gnumbox[r]{13}
\\
\gnumericPB{\raggedleft}\gnumbox[r]{2}
&\gnumericPB{\raggedleft}\gnumbox[r]{6}
&\gnumericPB{\raggedleft}\gnumbox[r]{10}
&\gnumericPB{\raggedleft}\gnumbox[r]{14}
\\
\gnumericPB{\raggedleft}\gnumbox[r]{3}
&\gnumericPB{\raggedleft}\gnumbox[r]{7}
&\gnumericPB{\raggedleft}\gnumbox[r]{11}
&\gnumericPB{\raggedleft}\gnumbox[r]{15}
\\
\gnumericPB{\raggedleft}\gnumbox[r]{4}
&\gnumericPB{\raggedleft}\gnumbox[r]{8}
&\gnumericPB{\raggedleft}\gnumbox[r]{12}
&\gnumericPB{\raggedleft}\gnumbox[r]{16}
\\
\end{longtable}

\gnumericTableEnd











Die dazugehörende tex-Datei in der die Tabelle stehen soll sieht so aus

\documentclass[12pt]{article}
\usepackage{ngerman,a4}
\usepackage[ansinew]{inputenc}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{color}
\usepackage{colordvi}
\usepackage{array}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{calc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{ifthen}

\usepackage{lscape}



\begin{document}
\def\inputGnumericTable{}


\begin{table}
\centering
\input{../Auswertungen/tabelle.tex}
\caption{Tabelle}
\label{tab}
\end{table}



\end{document}

countbela666
13-04-2007, 10:58
Wie ich's mir gedacht habe. Die von dem externen Programm erstellte Tabelle ist eine longtable, die bereits eine eigene caption-Funktionalität mitbringt und somit von sich aus bereits den table-counter erhöht.

Du hast jetzt folgende Möglichkeiten: Entweder du nutzt eine (da ich das Programm nicht kenne von mir nur angenommene) Möglichkeit von gnumeric, die caption bereits beim Erstellen der Tabelle einzubinden und verzichtest auf deinen caption-Befehl im Code oder du setzt den Tabellenzähler nach dem Einbinden jeder so erzeugten externen Tabelle händisch per \addtocounter{table}{-1) zurück.

Grüße
Marcel

sofa-surfer
13-04-2007, 11:01
Hallo,

offensichtlich exportiert dieses Gnumeric die Tabelle als longtable. Deren \caption muss aber schon innerhalb der Tabelle gesetzt werden und nicht erst danach (wie von dir). Der entsprechende Abschnitt ist in der exportierten tex-Datei vorgesehen, aber auskommentiert. Das dumme an der longtable ist, dass sie afaik den Tabellenzähler auch dann erhöht, wenn keine \caption explizit innerhalb der Tabelle gesetzt wird.

Du kannst nun also versuchen, das Programm zu veranlassen nicht als longtable zu exportieren. Oder aber du setzt die Überschrift schon innerhalb der exportierten Datei ein. Oder aber du setzt hinter jede Tabelle ein \addtocounter{table}{-1}.

Matthias

EDIT: mal wieder zu spät :D

smusecat
17-04-2007, 13:29
Wie ich's mir gedacht habe. Die von dem externen Programm erstellte Tabelle ist eine longtable, die bereits eine eigene caption-Funktionalität mitbringt und somit von sich aus bereits den table-counter erhöht.

Du hast jetzt folgende Möglichkeiten: Entweder du nutzt eine (da ich das Programm nicht kenne von mir nur angenommene) Möglichkeit von gnumeric, die caption bereits beim Erstellen der Tabelle einzubinden und verzichtest auf deinen caption-Befehl im Code oder du setzt den Tabellenzähler nach dem Einbinden jeder so erzeugten externen Tabelle händisch per \addtocounter{table}{-1) zurück.

Grüße
Marcel

Vielen Dank für die Hilfe. Ich hab die Vorschläge mal ausprobiert. Die einfachste Möglichkeit die funktioniert ist es, einfach nach jeder eingefügten Gnumeric-Tabelle \addtocounter{table}{-1} zu setzen. Eine andere Möglichkeit ist es, in den von Gnumeric ausgegebenen tex-Dateien die caption nachträglich von Hand einzugeben, allerdings muss man das \label dann ebenfalls in der Gnumeric-Tabelle eingeben. Der Nachteil daran ist leider das wenn man die Tabelle in Gnumeric ändert und erneut abspeichert natürlich die nachträglich eingefügte Überschrift überschrieben wird.

Eine Möglichkeit die caption bereits beim Erstellen der Tabelle einzubinden hab ich nicht gefunden, ebensowenig eine Möglichkeit das Gnumeric die Tabelle nicht als longtable schreibt.