%20%E5%85%A8%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%BE%E3%81%A7%E5%BA%83%E3%81%92%E3%82%8B.png)
tabularx テーブルの幅を、テキスト幅だけではなく、ほぼページ全体に広げたいと考えています。現在のイメージは次のとおりです (以下を使用) \usepackage{showframe}
。
テーブルの幅を画像の右外側のボックスの幅にしたいのですが、両側に適用します (両側に少しの空白が残るようにします)。これを行う方法を誰か知っていますか? コードは次のとおりです:
\documentclass[a4paper,12pt]{article}
\usepackage[margin=1.in]{geometry}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{ltablex}
\usepackage{siunitx}[input-decimal-markers=.]
\usepackage{lipsum}
\usepackage{threeparttable}
\usepackage{showframe}
\usepackage[sort, numbers, compress]{natbib}
\usepackage{amsmath}
\usepackage{makebox}
\usepackage[font=scriptsize,labelfont=bf,labelsep=period]{caption}
\usepackage[export]{adjustbox}
\usepackage[hidelinks]{hyperref}
\begin{document}
\renewcommand{\arraystretch}{2}
\begin{tiny}
\begin{tabularx}{\linewidth}{@{}XXXXXX@{}}
\caption{a table}\\
\toprule
\multicolumn{1}{l}{1}&\multicolumn{1}{l}{2}&\multicolumn{1}{c}{3 }&\multicolumn{1}{c}{4 }&\multicolumn{1}{c}{5}&\multicolumn{1}{c}{6} \\
\midrule
\textbf{text123 test test test test test test test}&textasddsa&textasdasd&textas sada &textasd asd adas das&test 123 test 123 test 123 test 123 test 123 tesrt 123 test 123 test 123\\
\\
\bottomrule
\end{tabularx}
\end{tiny}
\end{document}
答え1
テーブルを広くするには、textwidth
次の 2 つのオプションがあります。
- テキストの幅を局所的に広げる。例えば
adjustwidth
マクロを使うなど - 表のあるページを
landscape
方向付ける
のムウェ以下では、両方のオプションを検討します。
\documentclass[a4paper,12pt]{article}
\usepackage[margin=1 in]{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, ltablex, makecell}
\keepXColumns
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\setcellgapes{3pt}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\usepackage[strict]{changepage}
\usepackage{pdflscape}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[66]
\begin{adjustwidth}{}{-\dimexpr\marginparsep+\marginparwidth}
\footnotesize
\makegapedcells
\setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{@{}>{\bfseries}*{6}{L}@{}}
\caption{A wide table}\\
\toprule
\thead{1} & \thead{2} & \thead{3} & \thead{4} & \thead{5} & \thead{6} \\
\midrule
\endfirsthead
\caption*{Table~\thetable: A wide table \hfill(cont.)}\\
\toprule
\thead{1} & \thead{2} & \thead{3} & \thead{4} & \thead{5} & \thead{6} \\
\midrule
\endhead
\multicolumn{6}{r}{continue on the next page}
\endfoot
\bottomrule
\endlastfoot
% table body
text123 test test test test test test test
& textasddsa & textasdasd & textas sada & textasd asd adas das & test 123 test 123 test 123 test 123 test 123 tesrt 123 test 123 test 123 \\
\midrule
\lipsum*[66] & & & & & \\
\midrule
\lipsum*[66] & & & & & \\
\end{tabularx}
\end{adjustwidth}
\lipsum[66]
second option: table in landscape orientation
\begin{landscape}
\footnotesize
\makegapedcells
\setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{@{}>{\bfseries}*{6}{L}@{}}
\caption{A wide table}\\
\toprule
\thead{1} & \thead{2} & \thead{3} & \thead{4} & \thead{5} & \thead{6} \\
\endfirsthead
\caption*{Table~\thetable: A wide table \hfill(cont.)}\\
\toprule
\thead{1} & \thead{2} & \thead{3} & \thead{4} & \thead{5} & \thead{6} \\
\midrule
\endhead
\multicolumn{6}{r}{continue on the next page}
\endfoot
\bottomrule
\endlastfoot
% table body
\lipsum*[66] & & & & & \\
\midrule
\lipsum*[66] & & & & & \\
\midrule
\lipsum*[66] & & & & & \\
\end{tabularx}
\end{landscape}
\end{document}
一部の列に短い 1 行のテキストを含むセルがある場合、この列には列タイプを使用するのが適切ですl
。