如何使横向表格适合页面宽度?

如何使横向表格适合页面宽度?

这是我的 latex,列总是看起来超出页面宽度。我知道我使用 p 而不是 l 来设置宽度。但是,使用 p,表格会消失到下一页,那里是纵向模式。

\documentclass[runningheads]{llncs}

\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{cite}
\usepackage[export]{adjustbox}
\usepackage{multirow}
\usepackage{float}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\usepackage[normalem]{ulem}
\usepackage{array}

    \afterpage{%
    \clearpage% Flush earlier floats (otherwise order might not be correct)
    \thispagestyle{empty}% empty page style (?)
    \begin{landscape}% Landscape page
\useunder{\uline}{\ul}{}

\begin{table}[]
\begin{tabular}{llll}
\hline
\textbf{Name(Store)}                                   & \textbf{Purpose}                  & \textbf{Support}                                                                       & \textbf{Medical References}                                                                                         \\ \hline
{\ul IBS (Google Play)}                       & Pain Assistance          & No                                                                            & Unknown. There is no direct (cited) scientific basis. Authors on the website do have a medical background. \\
{\ul FODMAP A toZ (Google Play, Apple Store)} & Diet                     & No, but contacting a qualified physician before adjusting the diet is advised & Unknown, created by patient.                                                                               \\
{\ul MySymptoms (Google Play, Apple Store)}   & Journal (Diet, Symptoms) & No, but contacting a qualified physician before adjusting the diet is advised & Unknown. However the included blogs do.                                                                    \\
{\ul Curing IBS (Google Play)}                & Informative              & No                                                                            & Unknown, created by patient.                                                                               \\
{\ul My IBS Diary (Google Play)}              & Journal (Diet, Symptoms) & Yes, cvs file can be exported and sent to physician                           & Unknown                                                                                                    \\
{\ul Irritable Bowel Syndrome (Google Play)}  & Informative              & No                                                                            & Unknown                                                                                                    \\
{\ul Zemedy}                                  & Therapy                  & Yes, expert can be contacted in the app                                       & Yes. (Latest) Medical references are listed                                                                \\
{\ul Monash University FODMAP diet}           & Journal (Diet)           & No                                                                            & Yes. Created at Monash University                                                                          \\
{\ul Bristol Stool Chart}                     & Journal                  & Yet, csv file can be exported and sent to physician                           & Yes, namely the Bristol Stool Chart.                                                                       \\
                                              &                          &                                                                               &                                                                                                           
\end{tabular}
\end{table}

\captionof{table}{Table caption}% Add 'table' caption
    \end{landscape}
    \clearpage% Flush page
}

这就是结果 在此处输入图片描述

答案1

tabularx这是一个允许表格与文本宽度一样宽的版本。我还删除了table环境,因为这里不需要它:

\documentclass[runningheads]{llncs}

\usepackage{float}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\usepackage[normalem]{ulem}

\usepackage{tabularx}


\begin{document}


    \afterpage{%
    \clearpage% Flush earlier floats (otherwise order might not be correct)
    \thispagestyle{empty}% empty page style (?)
    \begin{landscape}% Landscape page
\useunder{\uline}{\ul}{}

%\begin{table}[]
\begin{tabularx}{\linewidth}{XlXX}
\hline
\textbf{Name(Store)}                                   & \textbf{Purpose}                  & \textbf{Support}                                                                       & \textbf{Medical References}                                                                                         \\ \hline
{\ul IBS  (Google Play)}                       & Pain Assistance          & No                                                                            & Unknown. There is no direct (cited) scientific basis. Authors on the website do have a medical background. \\
{\ul FODMAP A toZ  (Google Play, Apple Store)} & Diet                     & No, but contacting a qualified physician before adjusting the diet is advised & Unknown, created by patient.                                                                               \\
{\ul MySymptoms  (Google Play, Apple Store)}   & Journal (Diet, Symptoms) & No, but contacting a qualified physician before adjusting the diet is advised & Unknown. However the included blogs do.                                                                    \\
{\ul Curing IBS (Google Play)}                & Informative              & No                                                                            & Unknown, created by patient.                                                                               \\
{\ul My IBS Diary  (Google Play)}              & Journal (Diet, Symptoms) & Yes, cvs file can be exported and sent to physician                           & Unknown                                                                                                    \\
{\ul Irritable Bowel Syndrome (Google Play)}  & Informative              & No                                                                            & Unknown                                                                                                    \\
{\ul Zemedy}                                  & Therapy                  & Yes, expert can be contacted in the app                                       & Yes. (Latest) Medical references are listed                                                                \\
{\ul Monash University FODMAP diet}           & Journal (Diet)           & No                                                                            & Yes. Created at Monash University                                                                          \\
{\ul Bristol Stool Chart}                     & Journal                  & Yet, csv file can be exported and sent to physician                           & Yes, namely the Bristol Stool Chart.                                                                       \\
                                              &                          &                                                                               &                                                                                                           
\end{tabularx}

\captionof{table}{Table caption}% Add 'table' caption
    \end{landscape}
    \clearpage% Flush page
}


\end{document}

在此处输入图片描述


这里我使用了包sidewaystable中的环境rotating而不是landscape方法:

\documentclass[runningheads]{llncs}

\usepackage{float}
\usepackage[normalem]{ulem}

\usepackage{tabularx}
\usepackage{rotating}


\begin{document}



    \begin{sidewaystable}
\useunder{\uline}{\ul}{}


\begin{tabularx}{\linewidth}{XlXX}
\hline
\textbf{Name(Store)}                                   & \textbf{Purpose}                  & \textbf{Support}                                                                       & \textbf{Medical References}                                                                                         \\ \hline
{\ul IBS  (Google Play)}                       & Pain Assistance          & No                                                                            & Unknown. There is no direct (cited) scientific basis. Authors on the website do have a medical background. \\
{\ul FODMAP A toZ  (Google Play, Apple Store)} & Diet                     & No, but contacting a qualified physician before adjusting the diet is advised & Unknown, created by patient.                                                                               \\
{\ul MySymptoms  (Google Play, Apple Store)}   & Journal (Diet, Symptoms) & No, but contacting a qualified physician before adjusting the diet is advised & Unknown. However the included blogs do.                                                                    \\
{\ul Curing IBS (Google Play)}                & Informative              & No                                                                            & Unknown, created by patient.                                                                               \\
{\ul My IBS Diary  (Google Play)}              & Journal (Diet, Symptoms) & Yes, cvs file can be exported and sent to physician                           & Unknown                                                                                                    \\
{\ul Irritable Bowel Syndrome (Google Play)}  & Informative              & No                                                                            & Unknown                                                                                                    \\
{\ul Zemedy}                                  & Therapy                  & Yes, expert can be contacted in the app                                       & Yes. (Latest) Medical references are listed                                                                \\
{\ul Monash University FODMAP diet}           & Journal (Diet)           & No                                                                            & Yes. Created at Monash University                                                                          \\
{\ul Bristol Stool Chart}                     & Journal                  & Yet, csv file can be exported and sent to physician                           & Yes, namely the Bristol Stool Chart.                                                                       \\
                                              &                          &                                                                               &                                                                                                           
\end{tabularx}

\caption{Table caption}
    \end{sidewaystable}


\end{document}

在此处输入图片描述


最后这个例子包含了一些关于如何提高表格可读性的建议(我删除了下划线命令,从booktabs包中添加了水平标尺,并在列和行之间增加了一些水平和垂直空间。最后,我还使用了一些缩写来节省表格中的空间)

\documentclass[runningheads]{llncs}

\usepackage{float}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\usepackage[normalem]{ulem}

\usepackage{tabularx}
\usepackage{booktabs}


\begin{document}


    \afterpage{%
    \clearpage% Flush earlier floats (otherwise order might not be correct)
    \thispagestyle{empty}% empty page style (?)
    \begin{landscape}% Landscape page
\setlength\extrarowheight{3pt} 
\setlength{\tabcolsep}{6pt}

\begin{tabularx}{\linewidth}{>{\raggedright\arraybackslash}p{3cm}l>{\raggedright\arraybackslash}X>{\raggedright\arraybackslash}X}
\toprule
\textbf{Name(Store)}                                   & \textbf{Purpose}                  & \textbf{Support}                                                                       & \textbf{Medical References}                                                                                         \\ \midrule
{ IBS  (GP)}                       & Pain Assistance          & No                                                                            & Unknown. There is no direct (cited) scientific basis. Authors on the website do have a medical background. \\
{ FODMAP A toZ  (GP, AS)} & Diet                     & No, but contacting a qualified physician before adjusting the diet is advised & Unknown, created by patient.                                                                               \\
{ MySymptoms  (GP, AS)}   & Journal (Diet, Symptoms) & No, but contacting a qualified physician before adjusting the diet is advised & Unknown. However the included blogs do.                                                                    \\
{ Curing IBS (GP)}                & Informative              & No                                                                            & Unknown, created by patient.                                                                               \\
{ My IBS Diary  (GP)}              & Journal (Diet, Symptoms) & Yes, cvs file can be exported and sent to physician                           & Unknown                                                                                                    \\
{ Irritable Bowel Syndrome (GP)}  & Informative              & No                                                                            & Unknown                                                                                                    \\
{ Zemedy}                                  & Therapy                  & Yes, expert can be contacted in the app                                       & Yes. (Latest) Medical references are listed                                                                \\
{ Monash University FODMAP diet}           & Journal (Diet)           & No                                                                            & Yes. Created at Monash University                                                                          \\
{ Bristol Stool Chart}                     & Journal                  & Yet, csv file can be exported and sent to physician                           & Yes, namely the Bristol Stool Chart.                                                                       \\
  \bottomrule
  \multicolumn{4}{p{\textwidth}}{Abbreviations: GP = Google Play, AS = Apple Store}
\end{tabularx}

\captionof{table}{Table caption}% Add 'table' caption
    \end{landscape}
    \clearpage% Flush page
}


\end{document}

在此处输入图片描述

相关内容