我是 LYx 新手...当我以 PDF 版本编译文档时,我的表格似乎太宽了。这是我的源窗格。请帮忙!
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{float}
\usepackage{amsmath}
\usepackage{setspace}
\doublespacing
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\@ifundefined{date}{}{\date{}}
\makeatother
\usepackage{babel}
\begin{document}
\begin{table}[H]
\begin{tabular}{|c||c||c||c||c||c|}
\hline
& \textbf{Inspiration for new clothes} & \textbf{Purchase clothes/year} & \textbf{Period of year girls spend more on clothing} & \textbf{Priority for clothing} & \textbf{Girls prefer to shop with}\tabularnewline
\hline
\hline
\textbf{Maximum} & Style in stores & 50 times & Summer & Quality & Family\tabularnewline
\hline
\hline
\textbf{Minimum} & Celebrities & 3 times & Winter & Price & Alone\tabularnewline
\hline
\end{tabular}\protect\caption{Statistical Summaries}
\end{table}
\end{document}
答案1
只有一个建议,仅此而已,使用带环绕的居中列 ( \newcolumntype{C}{...}
)
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{float}
\usepackage{amsmath}
\usepackage{setspace}
\doublespacing
\makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. %% Because html converters don't know tabularnewline \providecommand{\tabularnewline}{\\} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\@ifundefined{date}{}{\date{}}
\makeatother
\usepackage{babel}
\usepackage[lmargin=1.5cm,rmargin=1.5cm]{geometry}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{table}[H]
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|*{7}{C{0.12\linewidth}|}}
\hline
\textbf{Increasing Age Effects} & \textbf{Clothes} & \textbf{Computer Interest} & \textbf{Computer Anxiety} & \textbf{Picky for Food} & \textbf{Motivational Tasks} & \textbf{Kids Interest in Toys}\tabularnewline
\hline
\hline
& Negative Correlation & Negative Correlation & Positive Correlation & & Negative Correlation & \tabularnewline
\hline
\textbf{Young Girls} & & & & Positive Correlation & & \tabularnewline
\hline
\textbf{Young Boys} & & & & Negative Correlation & & \tabularnewline
\hline
\textbf{Baby Girls} & & & & & & Negative Correlation\tabularnewline
\hline
\textbf{Baby Boys} & & & & & & Positive Correlation\tabularnewline
\hline
\end{tabular*}\protect\caption{\textbf{Correlation of Age with Different Interests}}
\end{table}
\end{document}
答案2
另一种解决方案是使用tabularx
环境和makecell
包:它的\thead
命令允许对单元格中的列标题和换行符进行通用格式设置。我还用 替换了双 \hline \hhline
,这样可以调整水平线之间的垂直间距。caption 包允许在序言中进行 capton 格式设置,并且有一个H
选项:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{caption}
\captionsetup{font = bf}
\usepackage{amsmath}
\usepackage{setspace}
\doublespacing
\makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. %% Because html converters don't know tabularnewline \providecommand{\tabularnewline}{\\} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\@ifundefined{date}{}{\date{}}
\makeatother
\usepackage{babel}
\usepackage[hmargin=1.5cm]{geometry}
\usepackage{array, tabularx, hhline}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}[H]
\setlength\doublerulesep{4pt}
\setlength\tabcolsep{4pt}
\setlength\extrarowheight{1pt}
\begin{tabularx}{\linewidth}{|*{7}{X|}}
\hline
\thead{Increasing & & & & & & \\ Age Effects} & \thead{Clothes} & \thead{Computer\\ Interest} & \thead{Computer\\ Anxiety} & \thead{Picky\\ for Food} & \thead{Motivational\\ Tasks} & \thead{Kids Interest\\ in Toys}\tabularnewline
\hhline{:=:=:=:=:=:=:=:}
& Negative Correlation & Negative Correlation & Positive Correlation & & Negative Correlation & \tabularnewline
\hline
\textbf{Young Girls} & & & & Positive Correlation & & \tabularnewline
\hline
\textbf{Young Boys} & & & & Negative Correlation & & \tabularnewline
\hline
\textbf{Baby Girls} & & & & & & Negative Correlation\tabularnewline
\hline
\textbf{Baby Boys} & & & & & & Positive Correlation\tabularnewline
\hline
\end{tabularx}
\caption{Correlation of Age with Different Interests}
\end{table}
\end{document}