Graphics, Figures & TablesUsing KOMA Script to insert table that's too wide

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
calvoutn
Posts: 1
Joined: Wed May 18, 2022 5:30 pm

Using KOMA Script to insert table that's too wide

Post by calvoutn »

Hi! I'm trying to create a table (it's the format required for this), what's too wide to fit in a A4 page. I've tried putting in landscape and it doesn't fit either. What I'm trying is to use KOMA Script to insert an A3 page for the table, but it doesn't reposition the header or the page itself.

Code: Select all

\documentclass[a4paper,12pt]{report}


\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{lipsum}
\usepackage{multicol} % Permite escribir en dos columnas.
\usepackage[spanish]{babel}
\usepackage{pdfpages}
\usepackage{tabularx}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage[paper=A4,pagesize]{typearea}
\usepackage{pdflscape}
\usepackage{bigstrut}

%--------------------------------------------------
%Para agregar citas en apa
%Para citar se usa el comando \cite{}
%Las referencias se modifican en el archivo sample.bib
\usepackage{apacite}
%----------------------------------------------

%%%%%%%% Estilo de footers and headers %%%%%%%%%
\usepackage{fancyhdr} %Headers y footers
 \pagestyle{fancy}
\fancyhf{}
\rhead{\textbf{Alumno: My name}}
\lhead{\textbf{Instalaciones sanitarias}}
\rfoot{Página \thepage}
 
\usepackage{titlesec}
\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}{\thechapter.}{1em}{\Huge}
\titlespacing*{\chapter}{0pt}{-19pt}{0pt}

\begin{document}
%-------------------------------------------------------------------------------
% Portada
%-------------------------------------------------------------------------------
\title{ \normalsize Universidad Tecnológica Nacional \\
		Introducción a la investigación
		\\[2.0cm]
		\noindent\rule{\textwidth}{1pt}\\[.4cm]
		\LARGE \textbf{Actividad individual 1} 
		\noindent\rule{\textwidth}{1pt}\\[.2cm]
		\normalsize \today \vspace*{5\baselineskip}}

\date{}

\author{
		 My name\\ 
		 My email}
%se debe incluir el comando \maketitle para hacer 
\maketitle

%Para hacer el indice solo es necesario agregar 
\tableofcontents
\clearpage

%-------------------------------------------------------------------------------
% Section title formatting
%\sectionfont{\scshape}
%-------------------------------------------------------------------------------

%-------------------------------------------------------------------------------
% BODY
%-------------------------------------------------------------------------------

\chapter{La ciencia moderna}

\lipsum% Placed on A3
\clearpage

\KOMAoptions{paper=A3,paper=landscape,pagesize}
\recalctypearea

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|p{13.215em}|p{30.285em}|r|}
    \hline
    \textbf{Preguntas que orientan la innovación} &
      \textbf{Caracterización del tipo de innovación tecnológica\newline{}} &
      \multicolumn{1}{p{27.785em}|}{\textbf{Identificar características de la investigación tecnológica que haya estado presente en cada tipo de innovación}}
      \bigstrut\\
    \hline
    Es esta única y  mejor manera de prender este aparato &
      De forma similar a la anterior, se relaciona a mejorar de forma incremental el producto para un uso más cómodo. Se relaciona con la mejora continua. &
      \multicolumn{1}{p{27.785em}|}{Se deberá dar más que nada un pensamiento ingenieríl del producto, en cuanto a su diseño para mejorar ergonomía y uso. }
      \bigstrut\\
    \hline
    \multicolumn{1}{|l|}{Existen nuevas tecnologías para cortar} &
      Se puede pensar de varias formas, ya que las nuevas tecnologías pueden implicar simplemente una mejora continua, en caso que se de una mejora en el sistema de las aspas únicamente, o algo radical en caso de que por ejemplo se automatice la tarea mediante el uso de un robot similar a las aspiradoras nuevas. &
      \multicolumn{1}{p{27.785em}|}{Se deberá hacer una investigación profunda sobre las soluciones modernas en productos similares, y también prestar ate}
      \bigstrut\\
    \hline
    El diseño de nuestro producto ayuda a una mejor postura? &
      Respetando el producto, se busca que su diseño sea más natural en su uso, dando lugar a una mejora continua. &
      
      \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\clearpage


\KOMAoptions{paper=A4,paper=portrait,pagesize}
\recalctypearea

\lipsum% Placed on A3


\KOMAoptions{paper=A4}
\recalctypearea
\end{document}
I tried to read a bit on it, but I couldn't go further than that.
Any help is apprecitated.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
tornado
Posts: 3
Joined: Fri May 13, 2022 8:37 am

Using KOMA Script to insert table that's too wide

Post by tornado »

You could use the

Code: Select all

adjustbox
package to wrap your table in and resize it to a smaller size that fits your page width.
User avatar
MjK
Posts: 89
Joined: Fri Jan 28, 2022 6:09 pm

Using KOMA Script to insert table that's too wide

Post by MjK »

calvoutn wrote:Hi! I'm trying to create a table (it's the format required for this), what's too wide to fit in a A4 page. I've tried putting in landscape and it doesn't fit either. What I'm trying is to use KOMA Script to insert an A3 page for the table, but it doesn't reposition the header or the page itself.
In your example you are using fancyhdr and so this package is responsible for the width of the header (and footer). So if you want to adapt fancyhdr's \headwidth with every change of the typing area, you shoult tell it fancyhdr. You can do this automatically using typearea's \AfterCalculatingTypearea. See the KOMA-Script manual for more information about this command.

And the page itself is also repositioned by typearea. But you are telling typearea that is should use the last used DIV value which is obviously not, what you want. So either set another DIV like here:

Code: Select all

\documentclass[a4paper,12pt]{report}

\usepackage[utf8]{inputenc}% Note: Note needed since April 2018 release of LaTeX
\usepackage{graphicx}
\usepackage{lscape}% Note: Also loaded by pdflscape below.
\usepackage{lipsum}
\usepackage{multicol} % Permite escribir en dos columnas. Note: Provides mix of differenc column numbers on the same page not only two colums like class option twocolumn
\usepackage[spanish]{babel}
\usepackage{pdfpages}
\usepackage{tabularx}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage[paper=A4,pagesize]{typearea}
\AfterCalculatingTypearea{\setlength{\headwidth}{\textwidth}}% Note: Change fancyhdr's page head width with every recalculation of the typing area and margins.
\usepackage{pdflscape}% Note: Could be improved by loading scrhack.
\usepackage{bigstrut}

%--------------------------------------------------
%Para agregar citas en apa
%Para citar se usa el comando \cite{}
%Las referencias se modifican en el archivo sample.bib
\usepackage{apacite}
%----------------------------------------------

%%%%%%%% Estilo de footers and headers %%%%%%%%%
\usepackage{fancyhdr} %Headers y footers
 \pagestyle{fancy}
\fancyhf{}
\rhead{\textbf{Alumno: My name}}
\lhead{\textbf{Instalaciones sanitarias}}
\rfoot{Página \thepage}
 
\usepackage{titlesec}
\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}{\thechapter.}{1em}{\Huge}
\titlespacing*{\chapter}{0pt}{-19pt}{0pt}

\begin{document}
%-------------------------------------------------------------------------------
% Portada
%-------------------------------------------------------------------------------
\title{ \normalsize Universidad Tecnológica Nacional \\
		Introducción a la investigación
		\\[2.0cm]
		\noindent\rule{\textwidth}{1pt}\\[.4cm]
		\LARGE \textbf{Actividad individual 1} 
		\noindent\rule{\textwidth}{1pt}\\[.2cm]
		\normalsize \today \vspace*{5\baselineskip}}

\date{}

\author{
		 My name\\ 
		 My email}
%se debe incluir el comando \maketitle para hacer 
\maketitle

%Para hacer el indice solo es necesario agregar 
\tableofcontents
\clearpage% Note: Makes no sense, because \chapter will add it automatically

%-------------------------------------------------------------------------------
% Section title formatting
%\sectionfont{\scshape}
%-------------------------------------------------------------------------------

%-------------------------------------------------------------------------------
% BODY
%-------------------------------------------------------------------------------

\chapter{La ciencia moderna}

\lipsum% Placed on A3
\clearpage% Note: Should be \cleardoublepage for case of twoside. See the manual.

\KOMAoptions{paper=A3,paper=landscape,DIV=20,pagesize}% Note: Use another DIV for this page. Note also: Option pagesize is the default with typearea for several years.

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|p{13.215em}|p{30.285em}|r|}
    \hline
    \textbf{Preguntas que orientan la innovación} &
      \textbf{Caracterización del tipo de innovación tecnológica\newline{}} &
      \multicolumn{1}{p{27.785em}|}{\textbf{Identificar características de la investigación tecnológica que haya estado presente en cada tipo de innovación}}
      \bigstrut\\
    \hline
    Es esta única y  mejor manera de prender este aparato &
      De forma similar a la anterior, se relaciona a mejorar de forma incremental el producto para un uso más cómodo. Se relaciona con la mejora continua. &
      \multicolumn{1}{p{27.785em}|}{Se deberá dar más que nada un pensamiento ingenieríl del producto, en cuanto a su diseño para mejorar ergonomía y uso. }
      \bigstrut\\
    \hline
    \multicolumn{1}{|l|}{Existen nuevas tecnologías para cortar} &
      Se puede pensar de varias formas, ya que las nuevas tecnologías pueden implicar simplemente una mejora continua, en caso que se de una mejora en el sistema de las aspas únicamente, o algo radical en caso de que por ejemplo se automatice la tarea mediante el uso de un robot similar a las aspiradoras nuevas. &
      \multicolumn{1}{p{27.785em}|}{Se deberá hacer una investigación profunda sobre las soluciones modernas en productos similares, y también prestar ate}
      \bigstrut\\
    \hline
    El diseño de nuestro producto ayuda a una mejor postura? &
      Respetando el producto, se busca que su diseño sea más natural en su uso, dando lugar a una mejora continua. &
      
      \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\clearpage% Note: See  \cleardoublepage note above.


\KOMAoptions{paper=A4,paper=portrait,pagesize}% Note: IMHO here additionally the original DIV sould be added.
\recalctypearea

\lipsum% Placed on A3: Note: This is not correct. Here we already have A4!


\KOMAoptions{paper=A4}% Note: Does not make much sense at the end of the document.
\recalctypearea
\end{document}
But I would recommend to use solution from section 20.2 of the KOMA-Script manual.

Note: Usually combining typearea with scrlayer-scrpage would be easier than fancyhdr. But depending on your setting you may also need to change the header width and alignment after changing the paper size, width of the typing area or the margins.
My main topics are KOMA-Script and other questions related to my packages. If I reply to any other topic or if you've not yet added a minimal working example, please do not expect any further response. And please don't forget to tag examples as code.
Post Reply