2

I am using scrbook and I designed a simple table. I absolutely need the table output exactly where I declared it. I read the manual and I agree that generally tables should be floating; however this is not the case.

Let me show you what I mean:

\documentclass[chapterprefix=true]{scrbook}
\setcounter{secnumdepth}{0}

\usepackage[table]{xcolor} %\usepackage{xcolor, graphicx} \usepackage{geometry} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[italian]{babel} \usepackage{textcomp} \usepackage{indentfirst} \usepackage{times} \usepackage{mathptmx} \usepackage{setspace} \usepackage{tikz}%per la flowchart \usetikzlibrary{positioning,chains} \doublespacing \usepackage{caption} %per aggiungere captions al PRISMA ed evitare il floating delle tavole \usepackage{booktabs} % For prettier tables \doublespacing

\definecolor{chaptergrey}{rgb}{0.7,0.7,0.7}

\let\raggedchapter\raggedleft \addtokomafont{disposition}{\normalfont} %\setkomafont{element}{commands} \setkomafont{title}{\color{cyan}\LARGE} \setkomafont{chapter}{\color{cyan}\LARGE} \setkomafont{subtitle}{\color{black}}

\renewcommand*{\chapterformat}{% \scalebox{3}{\color{cyan}\thechapter}% }

\begin{document} \author{}

\subject{Linea Guida}
\title{\textbf{Il trattamento laparoscopico di laparocele e ernie ventrali}}
\subtitle{}
\titlehead{}


\date{Gennaio 2022}

\frontmatter
\maketitle
\tableofcontents
\chapter{Intro}



\mainmatter
\part{Sviluppo della linea guida}
\chapter{one}

\textbf{Quesito 1: In termini di efficacia e sicurezza è preferibile l’approccio laparoscopico o quello a cielo aperto per il trattamento dei pazienti con ernia ventrale o laparocele?}


Il quesito n. 1 riguarda le indicazioni al trattamento laparoscopico. É stata presa in considerazione sia la popolazione generale di pazienti portatori di ernia ventrale o laparocele sia alcuni sottogruppi di popolazione (pazienti anziani, pazienti con obesità). 

\begin{table}
\centering
%   \caption{RACCOMANDAZIONI}
\begin{tabular}{llc}
%   \toprule % <-- Toprule here
    \multicolumn{3}{c}{\cellcolor{blue}\color{white}\textbf{RACCOMANDAZIONI}} \\ % <-- Combining three cells with alignment c| and content RACCOMANDAZIONI.
%   \midrule    

    \cellcolor{cyan}\color{white}{1a}  & \cellcolor{cyan}\color{white}\parbox{0.55\textwidth}{first statement}   & \cellcolor{cyan}\color{white}\parbox{0.35\textwidth}{CONDIZIONATA A FAVORE}            \\
    \midrule
    \cellcolor{cyan}\color{white}{1b}   &  \cellcolor{cyan}\color{white}\parbox{0.55\textwidth}{second statement}   & \cellcolor{cyan}\color{white}\parbox{0.35\textwidth}{CONDIZIONATA A FAVORE}            \\
    \midrule
    \cellcolor{cyan}\color{white}{1c}   &  \cellcolor{cyan}\color{white}\parbox{0.55\textwidth}{third statement}   & \cellcolor{cyan}\color{white}\parbox{0.35\textwidth}{CONDIZIONATA A FAVORE}            \\

    \bottomrule % <-- Bottomrule here

\end{tabular}

\end{table}

\section{PICO 1A:}
\textbf{ Nei pazienti con ernia ventrale o incisionale (P) è preferibile un intervento laparoscopico (I) o a cielo aperto (C)? 
    O= Mortalità, morbilità, recidiva, qualità della vita, durata ricovero, dolore postoperatorio, costi.}

\end{document}

The table needs to be read before the part that starts with "PICO" (where it is declared), but actually its output is after the word "costi." This will break the flow of reading before its content is a part of the text itself, even is designed in a graphic form. In other words I want the reader to read the first paragraph, then the table and the rest of the text at the end.

I found a few suggestions using "captions", or the "figure" environment, but I could not manage to achieve the result

  • 2
    No need to disable the floating mechanism for this particular table. Instead, you may want to use the optional argument of the table environment in order to influence the table's position to suit your needs. (\begin{table}[htbp] should work perfectly fine for this particular case.) For background information, you may want to take a look at How to influence the position of float environments like figure and table in LaTeX? and Keeping tables/figures close to where they are mentioned – leandriis Jan 01 '22 at 16:21
  • 2
    You may put you tabular in a center environment, and use \captionof{table}{Some caption} (load caption in your preamble). Unrelated: it has been more than three years that loading inputenc is no more necessary: the latex kernel nowadays expects utf8 by default. – Bernard Jan 01 '22 at 16:21
  • 2
    the only thing the table environment does is enable floating so simply don't use it, a tabular will never float – David Carlisle Jan 01 '22 at 16:24
  • Excellent! Both the solutions by @leandris and @David-Carlisle worked perfectly. I had previously tried the caption, but I was not able to malke it work (certainly I did something wrong). Thank you to @Bernard for the info about inputenc: I generally copy some old preamble that worked for me and I am not abreast on these changes; the update is very useful (I guess I have loaded several other things that I do not need!) – Fabio Campanile Jan 01 '22 at 17:06

0 Answers0