Leo Gürtler wrote:

how can I label a table for use with cross-references in a not-floating enivronments?

See the attached example LyX-file.
The solution uses(requires) babel and hyperref, so that the captionname is in the correct language and the references are linked.


As I found no better solution, I can provide this as LaTeX-package with the additional feature to use it with figures outside floats, if someone is interested.

regards Uwe
#LyX 1.3 created this file. For more info see http://www.lyx.org/
\lyxformat 221
\textclass article
\begin_preamble
\newcommand{\otabcap}[1]{
 \stepcounter{table}
 \tablename\space\thetable:\space #1}
\newcommand{\otablabel}[1]{
 \newcounter{#1}
 \setcounter{#1}{\thetable}
 \hypertarget{table.#1}{}
}
\newcommand{\otabref}[1]{%
 \hyperlink{table.#1}
  {\tableautorefname\space\arabic{#1}}%
}

\usepackage[gennarrow]{eurosym}
\usepackage{icomma}
\usepackage{textcomp}
\usepackage{soul}
\renewcommand{\underbar}[1]{\ul{#1}}

\usepackage[colorlinks=true, urlcolor=blue,
linkcolor=black, pdftitle={otabtest},
pdfauthor={Mustermann}, bookmarksnumbered=true,
pdfnewwindow=true, pdfstartview=XYZ,
pdfpagelayout=OneColumn,
bookmarksopen]{hyperref}
\usepackage[figure]{hypcap}

%Linkfläche für Querverweise vergrößern
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}
\renewcommand{\figureautorefname}{Abb.\negthinspace}
\renewcommand{\tableautorefname}{Tab.\negthinspace}
\renewcommand{\sectionautorefname}{Kap.\negthinspace}
\renewcommand{\subsectionautorefname}{Kap.\negthinspace}
\renewcommand{\subsubsectionautorefname}{Kap.\negthinspace}
\newlength{\abc}
\settowidth{\abc}{\space}
\renewcommand{\equationautorefname}{\hspace{-\abc}}

%Damit die Zeichen ° , · und × in LyX direkt eingegeben werden können.
\DeclareInputText{176}{\ifmmode^\circ\else\textdegree\fi}
\DeclareInputText{183}{\ifmmode\cdot\else\textperiodcentered\fi}
\DeclareInputText{215}{\ifmmode\times\else\texttimes\fi}

%setzt die Schwelle herauf, ab der Gleitumgebungen allein
%auf einer Seite erscheinen
\renewcommand{\floatpagefraction}{0.7}

%setzt die Schwelle herauf, ab der Gleitumgebungen unten
%auf einer Seite erscheinen dürfen
\renewcommand{\bottomfraction}{0.5}
\end_preamble
\options fleqn
\language ngerman
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize 12
\spacing single 
\papersize a4paper
\paperpackage a4
\use_geometry 0
\use_amsmath 1
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip medskip
\quotes_language german
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle empty
\bullet 1
        1
        34
        -1
\end_bullet
\bullet 2
        2
        35
        -1
\end_bullet
\bullet 3
        2
        7
        -1
\end_bullet

\layout Standard


\begin_inset Float table
wide false
collapsed true

\layout Caption


\begin_inset LatexCommand \label{cap:asdf}

\end_inset 

asdf
\layout Standard
\align center 

\begin_inset  Tabular
<lyxtabular version="3" rows="1" columns="2">
<features>
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" rightline="true" 
width="0">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\end_inset 


\layout Standard
\align center 

\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
otabcap{
\end_inset 

We
\series bold 

\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
otablabel{tabWe} 
\end_inset 


\begin_inset ERT
status Collapsed

\layout Standard
}
\end_inset 


\layout Standard
\align center 

\begin_inset  Tabular
<lyxtabular version="3" rows="5" columns="5">
<features>
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" rightline="true" 
width="0">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
</row>
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

we
\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\layout Standard


\begin_inset Float table
placement H
wide false
collapsed true

\layout Caption


\begin_inset LatexCommand \label{cap:bsdf}

\end_inset 

bsdf
\layout Standard
\align center 

\begin_inset  Tabular
<lyxtabular version="3" rows="1" columns="2">
<features>
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" rightline="true" 
width="0">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" 
usebox="none">
\begin_inset Text

\layout Standard

\end_inset 
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" 
rightline="true" usebox="none">
\begin_inset Text

\layout Standard

\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\end_inset 


\layout Standard

siehe 
\begin_inset LatexCommand \ref{cap:asdf}

\end_inset 

, 
\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
otabref{tabWe}
\end_inset 

 und 
\begin_inset LatexCommand \ref{cap:bsdf}

\end_inset 

.
\the_end

Reply via email to