0

I use a newenvironment to structure my list of symbols and list of abbreviations. In some documents there is only one of them. So I try to count the use of this environment to correct the offset in my list of table, otherwise it would count one or two tables more and start with two or three.

I tried it like this:

\newcounter{tableCounter}

\renewenvironment{theglossary}{\begin{longtable}[l]{@{}p{\dimexpr 2cm-\tabcolsep}p{0.8\hsize}}}{\stepcounter{tableCounter}\end{longtable}}}

\addtocounter{table}{-\value{tableCounter}}

EDIT:

\documentclass[fontsize=12pt,paper=a4,bibliography=totoc,headings=normal, titlepage=true,toc=listof,toc=indent,listof=entryprefix,twoside=false]{scrbook}
\usepackage{gensymb}
\usepackage{placeins}
\usepackage{chngcntr}
\usepackage{enumitem}
\usepackage[nonumberlist,acronym,toc]{glossaries}
\usepackage[autooneside=false,automark,headsepline]{scrlayer-scrpage}


\newcounter{tableCounter}

\counterwithout{table}{chapter}

\newglossarystyle{mylong}{
\setglossarystyle{long}
\renewenvironment{theglossary}{\begin{longtable}[l]{@{}p{\dimexpr 2cm-\tabcolsep}p{0.8\hsize}}}{\end{longtable}}}

%\stepcounter{tableCounter}

\addtocounter{table}{-\value{tableCounter}}

\newglossary{symbolslist}{syi}{syg}{}

\newglossaryentry{symb:R_GAIN}{name={R\textsubscript{GAIN}},description={Gain Resistor\hspace{5mm}[\ohm]},first={Gain Resistor (R\textsubscript{GAIN})},type=symbolslist,sort=R_GAIN}

\newacronym[plural=LED,firstplural=LED,description={Light Emitting Diode}]{LED}{LED}{Light Emitting Diode}

\makeglossaries

\begin{document}
\listoftables

\printglossary[type=symbolslist,style=mylong,title=List of symbols]

\printglossary[style=mylong,type=\acronymtype]

    \chapter{Chapter}
    Symbol: \gls{symb:R_GAIN}
    \newline
    Abbreviation: \gls{LED}
    \newline
    \begin{table}
    \centering
    \begin{tabular}{|c|c|}
    \hline 
    First & Second \\ 
    \hline 
    1 & 2 \\ 
    \hline 
    \end{tabular}
    \caption{First table}
    \label{tab:First table}
    \end{table}
    \end{document}

This MWE renders:

enter image description here enter image description here enter image description here enter image description here

How you can see, my list of tables starts with number 3.

PascalS
  • 826
  • 1
    Can't you just do \addtocounter{table}{-1} instead of the \stepcounter{tableCounter}? (Untested for lack of an MWE) I somehow feel that there should be a different solution to this problem altogether, though. But I'm not the person to find it, I'm afraid. – moewe May 18 '18 at 09:59
  • @moewe Yes I could, but that is a static solution and will not work in all three cases (only a list of tables, only a list of abbreviations or a list of tables AND a list of abbreviations) – PascalS May 18 '18 at 10:11
  • Mhh, I guess I haven't fully understood your problem then. My code should simply ignore the glossary entry for the table counter. – moewe May 18 '18 at 10:31
  • That would work too for me :) But how can I ignore these tables in a \renewenvironment ? – PascalS May 18 '18 at 10:42
  • Sorry, I can't follow. I would need a full MWE that includes all the possible use cases your are thinking about along with an explanation what the expected output would be. Maybe https://tex.stackexchange.com/q/32553/35864 can help you, but that also suggests \addtocounter{table}{-1}... There also is https://tex.stackexchange.com/a/33414/35864 – moewe May 18 '18 at 11:02
  • I will add a complete MWE after work! Thanks for your support! – PascalS May 18 '18 at 11:57
  • @moewe I hope this help you to understand my problem. – PascalS May 18 '18 at 15:05
  • \newglossarystyle{mylong}{% \setglossarystyle{long} \renewenvironment{theglossary}{\begin{longtable}[l]{@{}p{\dimexpr 2cm-\tabcolsep}p{0.8\hsize}}}{\end{longtable}\addtocounter{table}{-1}}} (mod line breaks) works for me. – moewe May 18 '18 at 15:23
  • Perfect! Write that as an answer and I will accept :) – PascalS May 18 '18 at 15:43

1 Answers1

1

A very quick hack is to add \addtocounter{table}{-1} directly after the \end{longtable}.

But you could also load caption and use the starred version of longtable:

\begin{longtable*}{...}
...
\end{longtable*}

See also Longtable caption numbering

moewe
  • 175,683
  • Where do I have to add the '*' in my code? Immediately after longtable is not possible. – PascalS May 18 '18 at 16:02
  • @Passe You simply write \begin{longtable*} instead of \begin{longtable} and the same for \end{longtable}. But you will have to load the caption package: \usepackage{caption}. Of course in that case the \addtocounter is not needed any more. – moewe May 18 '18 at 16:04
  • Gotcha! I missed \end{longtable*} Thanks a lot! – PascalS May 18 '18 at 16:08