1

I have a long list of risks I want to put in my document.

I manage to make it work with longtable as can be seen in pic1 (It's in portguguese because it's my masters dissertaion).

enter image description here

The problem I'm facing here is that there's a configuration in the template that separates Tables from "Quadros" (which are mainly used for text and have the outer lines). This table should be a "Quadro" not a "Tabela" and should be included in that list.

I'm facing this problem because I am using a package called ABNTex2 which takes everything into the right formatting for my masters and one of the things created was a new float Quardo to take care of this differentiation

This is how a Quadro is usually instantiated:

\begin{quadro}[htb]
\caption{Editores de Texto Livres}
\label{quadro:editores_texto_livres}
\centering
\begin{tabular}{|l|l|r|}        \hline
Editor     & Multiplataforma & Específico para Latex \\ \hline
Kwriter    & Sim             & Não                   \\
Texmaker   & Sim             & Sim                   \\
Kile       & Sim             & Sim                   \\
Geany      & Sim             & Não                   \\ \hline
\end{tabular}
\end{quadro}

If I try to encapsulate the long table in the Quadro float, it simply doesn't show up, And I'm pretty sure it's because it's just too long.

So what I'm asking for help is either:

1- is there a way to change this code in order to allow the quadro to span multiple pages thus allowing the long table to be inside it? or another way to just make the float accept the longtable?

\newcommand{\listquadroname}{Lista de quadros}
\newcommand{\quadroname}{Quadro}
\newcommand{\quadrorefname}{Quadro}
\newcommand{\chartautorefname}{Quadro}

\addto\captionsenglish{% ingles
    \renewcommand{\listquadroname}{List of charts}
    \renewcommand{\quadroname}{Chart}
    \renewcommand{\quadrorefname}{Chart}
    \renewcommand{\chartautorefname}{Chart}
}

\newfloat{quadro}{htbp}{loq}[chapter]
\floatname{quadro}{\quadroname}
\floatstyle{plaintop}
\restylefloat{quadro}
\newlistof{listofquadros}{loq}{\listquadroname}
\newlistentry{quadro}{loq}{0}
\renewcommand{\thequadro}{\thechapter.\@arabic\c@quadro}
\setfloatadjustment{quadro}{\centering}

\renewcommand{\cftquadroname}{\quadroname\space}
\renewcommand*{\cftquadroaftersnum}{\hfill\textendash\hfill}

2- Is there a way to only change the name and list this specific table belongs to?

3- Last resort, how do I remove the outer vertical lines? (So as to make it count as a "Tabela")

1 Answers1

2

A first try. This only shows what need to patch and may certainly need to change according to your mwe.

\documentclass{report}

% \usepackage[strut=off]{caption}
\usepackage{float}
\usepackage{longtable}
\usepackage{xpatch}

\newcommand{\listquadroname}{Lista de quadros}
\newcommand{\quadroname}{Quadro}
\newcommand{\quadrorefname}{Quadro}
\newcommand{\chartautorefname}{Quadro}

\newfloat{quadro}{htbp}{loq}[chapter]
\floatname{quadro}{\quadroname}
\floatstyle{plaintop}
\restylefloat{quadro}

\makeatletter
\renewcommand{\thequadro}{\thechapter.\@arabic\c@quadro}

% patch longtable internal macros to use counter "quadro" and write to ".loq"
\xpatchcmd\LT@array
  {\refstepcounter{table}}
  {\refstepcounter{quadro}}
  {}{\fail}

% handle compatibility with caption package
\@ifpackageloaded{caption}{
  \renewcommand\LTcaptype{quadro}
}{
  \xpatchcmd\LT@c@ption
    {\fnum@table}
    {\fnum@quadro}
    {}{\fail}

  \xpatchcmd\LT@c@ption
    {\addcontentsline{lot}{table}{\protect\numberline{\thetable}{#2}}}
    {\addcontentsline{loq}{quadro}{\protect\numberline{\thequadro}{#2}}}
    {}{\fail}
}
\makeatother


\begin{document}
\listof{quadro}{\listquadroname}

\chapter{title}

\begin{quadro}[htb]
  \caption{Editores de Texto Livres}
  \label{quadro:editores_texto_livres}
  \centering
  \begin{tabular}{|l|l|r|}        \hline
    Editor     & Multiplataforma & Específico para Latex \\ \hline
    Kwriter    & Sim             & Não                   \\
    Texmaker   & Sim             & Sim                   \\
    Kile       & Sim             & Sim                   \\
    Geany      & Sim             & Não                   \\ \hline
  \end{tabular}
\end{quadro}

\begin{longtable}{cc}
  \caption{This is a longtable title} \\
  a & b \\
  c & d
\end{longtable}
\end{document}

enter image description here

muzimuzhi Z
  • 26,474
  • I actually recently noticed it doesn't fully work. I'm not using a single document via a normal compiler. I'm using Overleaf.

    There is a .cls file.

    If I put the commented commands into the cls it actually works but the counters break the rest of the code.

    If I put it into the tex file it doesn't break the code but doesn't include the tables into the quadro list

    – Victor Archela Nov 27 '20 at 04:21
  • @VictorArchela Could you prepare a new MWE in which the problem is reproducible? The MWE can be in the form of a share-by-link editable Overleaf project. – muzimuzhi Z Nov 27 '20 at 10:08
  • 2
    I put it as the right answer again, the reason why I was getting errors to put your code into the .cls what because there where other lines that use the at as a letter after this def, so I just put these lines in and it worked great =D

    % patch longtable internal macros to use counter "quadro" and write to ".loq" & % handle compatibility with caption package

    Thanks again

    – Victor Archela Nov 27 '20 at 20:50