1

I have difficulties with adjustbox. I had created a subsection and inside it is a table and this table moves to another subsection and I do not know how to fix this problem. I hope your help, please:

use

\documentclass[14pt,a4paper]{extarticle}

example of subsection

\subsection{Operacionalización de Variables}

\begin{quote}

\begin{table}[]
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{|l|l|c|l|c|}
\hline
\textbf{Variable} & \textbf{Dimension} & \multicolumn{1}{l|}{\textbf{Indicador}} & \textbf{Sub Indicador} & \multicolumn{1}{l|}{\textbf{Escala de Medición}} \\ \hline
\multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Factores \\ Demográficos\end{tabular}} & Sexo & \begin{tabular}[c]{@{}c@{}}Hombre      \\ Mujer\end{tabular} &  & Nominal \\ \cline{2-5} 
 & Lugar de residencia & \begin{tabular}[c]{@{}c@{}}zona urbana  \\ zona urbana marginal\\ zona marginal\end{tabular} &  & Nominal \\ \hline
\multicolumn{1}{|c|}{\begin{tabular}[c]{@{}c@{}}Factores \\ Economicos\end{tabular}} & \multicolumn{1}{c|}{Condición económica} & Ingresos & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}\textless{}1000\\ 1001 -1200\\ 1200 -1300\\ 1300 -1600\\ \textgreater{}1600\end{tabular}} & Ordinal \\ \hline
\end{tabular}
\end{adjustbox}
\end{table}

 \end{quote}

enter image description here

  • Welcome to TeX.SX! Why do you use \begin{table}...\end{table}? This will make the box with the tabular float around to where ever TeX thinks there is enough space. – gernot Jul 23 '18 at 14:30
  • he had used this page tablesgenerator.com and I copied the result, did I delete the \begin {table} ? – royer Jul 23 '18 at 14:35
  • Remove \begin{table}...\end{table}` and replace \textwidth by \linewidth. Note that parts of your page may stay blank if the table doesn't fit at this point. Moreover, using \begin{quote}...\end{quote} reduces the width available for the tabular. – gernot Jul 23 '18 at 14:39
2

You might also look at the needspace package. This is easier to show than explain.

\documentclass[14pt,a4paper]{extarticle}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{needspace}

\newsavebox{\tempbox}% just in case

\begin{document}
\setcounter{section}{2}
\setcounter{subsection}{8}
\rule{1pt}{25\baselineskip}% threshold for new page

\setbox\tempbox=\vbox{%
\subsection{Operacionalización de Variables}

\begin{adjustbox}{max width=\textwidth}
\begin{tabular}[b]{|l|l|c|l|c|}
\hline
\textbf{Variable} & \textbf{Dimension} & \multicolumn{1}{l|}{\textbf{Indicador}} & \textbf{Sub Indicador} & \multicolumn{1}{l|}{\textbf{Escala de Medición}} \\ \hline
\multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Factores \\ Demográficos\end{tabular}} & Sexo & \begin{tabular}[c]{@{}c@{}}Hombre      \\ Mujer\end{tabular} &  & Nominal \\ \cline{2-5} 
 & Lugar de residencia & \begin{tabular}[c]{@{}c@{}}zona urbana  \\ zona urbana marginal\\ zona marginal\end{tabular} &  & Nominal \\ \hline
\multicolumn{1}{|c|}{\begin{tabular}[c]{@{}c@{}}Factores \\ Economicos\end{tabular}} & \multicolumn{1}{c|}{Condición económica} & Ingresos & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}\textless{}1000\\ 1001 -1200\\ 1200 -1300\\ 1300 -1600\\ \textgreater{}1600\end{tabular}} & Ordinal \\ \hline
\end{tabular}
\end{adjustbox}}

\needspace{\ht\tempbox}\unvbox\tempbox

\end{document}
1

Your table (i.e. the tabular) is wrapped in a table environment which is a so called 'float', i.e. it floats through the text and is placed on a suitable position, mostly on a page boundary. There are ways to change this (see e.g. How to influence the position of float environments like figure and table in LaTeX?) but in your case it might be better to force a non-floating table. The adjustbox package helps you here, just use the nofloat=table key. If you need extra vertical space (as replacement for the quote environment) then also add the vspace=<amount> key.

\documentclass[14pt,a4paper]{extarticle}
\usepackage{adjustbox}
\usepackage{blindtext}
\usepackage{multirow}
\begin{document}
\blindtext

\subsection{Operacionalización de Variables}
\begin{adjustbox}{max width=\textwidth,nofloat=table,vspace=\medskipamount}
\begin{tabular}{|l|l|c|l|c|}
\hline
\textbf{Variable} & \textbf{Dimension} & \multicolumn{1}{l|}{\textbf{Indicador}} & \textbf{Sub Indicador} & \multicolumn{1}{l|}{\textbf{Escala de Medición}} \\ \hline
\multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Factores \\ Demográficos\end{tabular}} & Sexo & \begin{tabular}[c]{@{}c@{}}Hombre      \\ Mujer\end{tabular} &  & Nominal \\ \cline{2-5} 
 & Lugar de residencia & \begin{tabular}[c]{@{}c@{}}zona urbana  \\ zona urbana marginal\\ zona marginal\end{tabular} &  & Nominal \\ \hline
\multicolumn{1}{|c|}{\begin{tabular}[c]{@{}c@{}}Factores \\ Economicos\end{tabular}} & \multicolumn{1}{c|}{Condición económica} & Ingresos & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}\textless{}1000\\ 1001 -1200\\ 1200 -1300\\ 1300 -1600\\ \textgreater{}1600\end{tabular}} & Ordinal \\ \hline
\end{tabular}
\end{adjustbox}

\blindtext
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.