表格對於頁面來說太寬

表格對於頁面來說太寬

我正在嘗試在我的頁面上放置一個相當大的表格。對於頁面來說太寬了。我嘗試過類似的東西

\begin{longtable}{| p{0.14\textwidth} | p{0.14\textwidth} | 
p{0.14\textwidth} | p{0.14\textwidth} | p{0.14\textwidth} | 
p{0.14\textwidth} | p{0.14\textwidth} |}

因為我有七列。

我現在遇到的問題之一是,當我使用 時scrartcl,註釋空間也包含在其中\textwidth,但當然我想保持在正常限制內。

另外,我已經在使用 footnotesize,但它不會分隔單字 --> 如果它們太長,它們會部分寫在下一列。

我現在需要一種方法,使表格適合“正常”頁面寬度(如圖所示showframe),並添加換行符或分隔單詞,以避免寫入下一列。

我沒有發布一個最小的範例,因為我對所有可能的解決方案持開放態度(但它應該使用類似 longtable 的東西,如果可能的話,調整與 相關的列大小\textwidth)。
(抱歉,如果這看起來有點亂)

\begin{footnotesize}
\begin{center}
  \begin{longtable}{| p{0.14\textwidth} | p{0.14\textwidth} |
  p{0.14\textwidth} | p{0.14\textwidth} | p{0.14\textwidth} | 
  p{0.14\textwidth} | p{0.14\textwidth} |}
    \hline 
  \textbf{Variable} & \textbf{Kurzbezeichnung} & \textbf{Frage} & \textbf{type} & \textbf{value label} & \textbf{Range} & \textbf{missing value}\\
  \hline
  \endhead % all the lines above this will be repeated on every page
  ffhrwoggbgbgfieh & fefgogergeroigregb & fhoergregre & fhoerghergie & herogheggire & hgieghrgri & ngjreoigehrero\\
  \hline
  \caption{Alle Variablen von der Dokumentation aus dem Codebuch.}
  \label{tab:VarDoku}
  \end{longtable}
\end{center}
\end{footnotesize}

答案1

這麼窄的寬度無法容納“Kurzbezeichnung”,所以我將其縮寫為“KB”。

\documentclass{article}
\usepackage{longtable,calc,array}

\newlength\alicewidth

\begin{document}

\begingroup\footnotesize
\setlength{\alicewidth}{\textwidth/7-2\tabcolsep-8\arrayrulewidth/7}
\begin{longtable}{|*{7}{>{\raggedright\arraybackslash}p{\alicewidth}|}}
\hline
\textbf{Variable} & \textbf{KB} & \textbf{Frage} &
  \textbf{type} & \textbf{value label} & \textbf{Range} & \textbf{missing value}\\
\hline
\endhead % all the lines above this will be repeated on every page

ffhrwo ggbgbg fieh & fefgo gerge roigr egb & fhoerg regre & fhoerg hergie &
 herogh eggire & hgieg hrgri & ngjreoi gehrero\\

\hline
\caption{Alle Variablen von der Dokumentation aus dem Codebuch.\label{tab:VarDoku}}
\end{longtable}
\endgroup

\end{document}

在此輸入影像描述

答案2

我將使用該包,它結合了和ltablex的功能,並對所有列標題採用通用格式。此外,表格標題通常放在longtabletabularxmakecell多於為了方便讀者,特別是在多頁表的情況下:

\documentclass[a4paper]{scrartcl}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{caption, ltablex, makecell}%
\captionsetup{font=footnotesize, labelfont=sc}
\renewcommand\theadfont{\footnotesize\bfseries}
\usepackage{showframe} %
\renewcommand\ShowFrameLinethickness{0.3pt}
\renewcommand{\tabularxcolumn}[1]{>{\footnotesize\arraybackslash}p{#1}}

\begin{document}

\
\keepXColumns
\begin{tabularx}{\linewidth}{|*{7}{ X|}}
  \caption{Alle Variablen von der Dokumentation aus dem Codebuch.}\medskip
  \label{tab:VarDoku}\\
  \hline \thead{Variable} & \thead{Kurzbe- & & & & & \\zeichnung} & \thead{Frage} & \thead{Type} & \thead{Value\\ label} & \thead{Range} & \thead{Missing\\ value}\\
  \hline
  \endfirsthead
  \hline
  \thead{Variable} & \thead{Kurzbe- & & & & & \\zeichnung} & \thead{Frage} & \thead{type} & \thead{value\\ label} & \thead{Range} & \thead{missing\\ value}\\
  \hline
  \endhead % all the lines above this will be repeated on every page
  ffhrwogg bgbgfieh & fefgogerge roigregb & fhoergregre & fhoerghergie & herogheggire & hgieghrgri & ngjreoigeh rero \\

  \hline
\end{tabularx}

\end{document} 

在此輸入影像描述

相關內容