0

Edit: I have included all packages from my document as well (I know there are too many. As I still am a beginner in Latex, I add every new package when I try something found on the forums).

I have a question regarding fitting tables. For my thesis I have to name all stakeholders, which I created an Appendix for. The table itself should fit the page in which the chapter title is located, however the table how much I try is put on a new page (even when I make the table way smaller using \scriptsize, it does not fit). The code I use is:

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper, total={6.8in, 9in}]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{gensymb}
\usepackage[hidelinks,draft]{hyperref}
\def\UrlBreaks{\do\/\do-}
\usepackage{pdfpages}
\usepackage[official]{eurosym}
\usepackage{wasysym}
\usepackage{multirow}
\usepackage{accents}
\usepackage{verbatim} 
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage{blindtext}
\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[none]{hyphenat}
\usepackage{enumitem}
\usepackage{subcaption}
\usepackage[titletoc]{appendix}
\usepackage{pdflscape}
\usepackage[normalem]{ulem}
\useunder{\uline}{\ul}{}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{rotfloat}
\usepackage{newclude}
\usepackage{csquotes}
\usepackage{natbib}
\usepackage{chngcntr}
\counterwithout{table}{chapter}
\counterwithout{figure}{chapter}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage[nonumberlist, acronym]{glossaries}
\makeglossaries
\usepackage{wrapfig}
\usepackage{calligra}
\usepackage{booktabs}
\usepackage[normalem]{ulem}
\useunder{\uline}{\ul}{}
\usepackage{varwidth}

%----------------------------------------------------------------------------------------
%   Chapter settings
%----------------------------------------------------------------------------------------

\usepackage{titlesec, blindtext, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}

%%% Add this %%%
\titlespacing*{\chapter}{0pt}{0}{15pt}
\titlespacing*{name=\chapter, numberless}{0pt}{-30pt}{10pt}
%\titlespacing*{\chapter}{0pt}{30pt}{30pt}                  Original values
%\titlespacing*{name=\chapter,numberless}{0pt}{-30pt}{10pt} Original values

%%%   End   %%%

\begin{document}

\chapter{Project stakeholders} \label{app:stakeanal}
\begin{table}[htp]
\centering
\rotatebox{90}{%
  \begin{varwidth}{\textheight}
  \caption{Stakeholder analysis}\label{my-label}
  \footnotesize
  \begin{tabular}{@{}lllll@{}}
  \toprule
  \textbf{Stakeholder} & \textbf{Position} & \textbf{Interest} &
  \textbf{Influence} & \textbf{Key interest} \\
  \midrule
  Name & Position & Medium & High & Description \\
  Name & Position & Medium & High & Description \\
  Name & Position & Medium & High & Description \\
  Name & Position & Medium & High & Description \\
  \bottomrule
  \end{tabular}
  \end{varwidth}%
}
\end{table}

Can you guys help me fix it, it look so easy, yet it is so hard! I also tried using landscape, however this is also not possible as I do not want my chapter title to change from its top vertical position to top horizontal position.

5
  • 1
    Welcome, without checking the maual ... didn't sidewaystable always start on a new page? How about rotating?
    – Johannes_B
    Jan 9 '19 at 10:50
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Tiuri
    Jan 9 '19 at 10:51
  • Since I am still quite new to writing in Latex (this is my first document), I still haven't figured out everything. After checking, I see that sidewaystable automatically puts it on a new page. Thanks. I tried using \rotatebox, however I could not rotate the caption alongside with it as well!. Any tips?
    – John
    Jan 9 '19 at 10:57
  • Try to avoid to rotate the table - that's bad for the reader. On a page with a chapter title the difference between remaining height and width isn't so large, so quite often it is possible to set the table in portrait. Jan 9 '19 at 11:03
  • You shouldn't modify your question that way.
    – egreg
    Jan 9 '19 at 11:19
1

With sidewaystable the float will always go to a new page.

\documentclass{book}
\usepackage{rotating,booktabs,varwidth}

\begin{document}

\chapter{Project stakeholders} \label{app:stakeanal}
\begin{table}[htp]
\centering

\rotatebox{90}{%
  \begin{varwidth}{\textheight}
  \caption{Stakeholder analysis}\label{my-label}
  \footnotesize

  \begin{tabular}{@{}lllll@{}}
  \toprule
  \textbf{Stakeholder} & \textbf{Position} & \textbf{Interest} &
  \textbf{Influence} & \textbf{Key interest} \\
  \midrule
  Name & Position & Medium & High & Description \\
  Name & Position & Medium & High & Description \\
  Name & Position & Medium & High & Description \\
  Name & Position & Medium & High & Description \\
  \bottomrule
  \end{tabular}
  \end{varwidth}%
}
\end{table}

\end{document}

enter image description here

7
  • when I try to use the code you provided me in my document it still is not working. I edited my question and put my entire code there (with all packages I keep adding as I try out new ways to do something). Could you help find out the problem? Thanks!
    – John
    Jan 9 '19 at 11:13
  • @John: I had to remove subfigure and chngcntr packages because the clash with others. Then it compiled fine. Jan 9 '19 at 11:41
  • The varwidth will stop having an effect when the OP uses the subcaption package. I guess it adds a minipage with \textwidth or something else then for \caption. That's why it is larger then it should be after rotating. Jan 9 '19 at 11:50
  • Using the code provided (and keep the packages I have, exluding the clahsing ones) it still does not work for me. The table stays on the bottom of the 2nd page
    – John
    Jan 9 '19 at 11:58
  • @John: Remove the subcaption package and compare. Might also work with some other subcaption setting. Jan 9 '19 at 12:00

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.