![表格對於頁面來說太寬](https://rvso.com/image/348622/%E8%A1%A8%E6%A0%BC%E5%B0%8D%E6%96%BC%E9%A0%81%E9%9D%A2%E4%BE%86%E8%AA%AA%E5%A4%AA%E5%AF%AC.png)
我正在嘗試在我的頁面上放置一個相當大的表格。對於頁面來說太寬了。我嘗試過類似的東西
\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
的功能,並對所有列標題採用通用格式。此外,表格標題通常放在longtable
tabularx
makecell
多於為了方便讀者,特別是在多頁表的情況下:
\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}