Tabularx 居中,宽度大于文本宽度

Tabularx 居中,宽度大于文本宽度

我正在尝试实现这一点:

\documentclass[preprint,12pt]{elsarticle}

\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage[export]{adjustbox}[2011/08/13]
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{booktabs}
\usepackage{ltablex}
\usepackage{lineno}
\usepackage{color}
\usepackage{url}

\begin{document}

...

\begin{tabularx}{1.2\textwidth}{|m{4.5cm}|X|}\hline
Function & Indicator \\ \hline
\endhead

Function 1\newline Entrepreneurial\newline activities & No. of companies\newline Size of companies\newline Turnover of companies\newline No. of niche projects or experiments \newline No. of companies entering/exiting the innovation system\newline How innovative are they?\\\hline\

Function 2\newline Knowledge development & \begin{tabular}{p{4cm}|p{4cm}|p{3cm}}
Learning by searching  (R\&D) & Learning by doing & Learning by using\\\hline
No. of patents & No. of products produced & No. of users\\\hline
No. of research projects & No. of niche products & No. of niche projects\\\hline
No. of scientific papers & Product quality & User reviews\\
\end{tabular}\\\hline

Function 3\newline Knowledge diffusion through networks & 
No. of conferences \newline
No. of seminars \newline
No. of joint research projects \newline
Quality of formal and informal contacts between different actors \newline
Barriers to communication across networks \\\hline

Function 4\newline Guidance of the search & 
Goals \newline
Policy programmes \newline
Technological best practices and examples \newline
Ambitious/long terms objectives\\\hline

Function 5\newline Market formation & 
Market size \newline
Market characteristics (niche market or broader) \newline
Availability of market subsidies \newline
Motivation for buyers\\\hline

Function 6\newline Resources mobilization & 
No. and kind of financial resources \newline
No. of physical resources \newline
No. of human resources (research personnel/skilled labour) \newline
Skill level of workers \newline
Quality of education in the field\\\hline

Function 7\newline Creation of legitimacy & 
Public opinion of the technology \newline
Amount of resistance in regime \newline
Lobbying activities by innovation system members for financial and political support\\\hline
\caption{An overview of indicators for the FIS approach}
\label{tab:2}
\end{tabularx}

但是,存在一些问题。也就是说,嵌套在 tabularx 单元格中的表格有太多填充,当我尝试将其居中时,tabularx它不起作用。我见过如何让太宽的表格居中?或者中心图形的宽度大于 \textwidth,但无济于事。

有人知道我怎样才能做我想做的事情吗?

答案1

本地添加\setlength\LTleft{-0.1\textwidth}

\documentclass[preprint,12pt]{elsarticle}

\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage[export]{adjustbox}[2011/08/13]
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{booktabs}
\usepackage{ltablex}%{tabularx}%
\usepackage{lineno}
\usepackage{color}
\usepackage{url}
\usepackage{ragged2e, changepage, lipsum}%

 \begin{document}
\lipsum[11]
...

{\setlength\LTleft{-0.1\textwidth}%
\begin{tabularx}{1.2\textwidth}{| >{\RaggedRight}m{4.5cm}|X|}
\hline
Function & Indicator \\ \hline
\endhead

Function 1\newline Entrepreneurial\newline activities & No. of companies\newline Size of companies\newline Turnover of companies\newline No. of niche projects or experiments \newline No. of companies entering/exiting the innovation system\newline How innovative are they?\\\hline\

Function 2\newline Knowledge development & \begin{tabular}{p{4cm}|p{4cm}|p{3cm}}
Learning by searching (R\&D) & Learning by doing & Learning by using\\\hline
No. of patents & No. of products produced & No. of users\\\hline
No. of research projects & No. of niche products & No. of niche projects\\\hline
No. of scientific papers & Product quality & User reviews\\
\end{tabular}\\\hline

Function 3\newline Knowledge diffusion through networks &
No. of conferences \newline
No. of seminars \newline
No. of joint research projects \newline
Quality of formal and informal contacts between different actors \newline
Barriers to communication across networks \\\hline

Function 4\newline Guidance of the search &
Goals \newline
Policy programmes \newline
Technological best practices and examples \newline
Ambitious/long terms objectives\\\hline

Function 5\newline Market formation &
Market size \newline
Market characteristics (niche market or broader) \newline
Availability of market subsidies \newline
Motivation for buyers\\\hline

Function 6\newline Resources mobilization &
No. and kind of financial resources \newline
No. of physical resources \newline
No. of human resources (research personnel/skilled labour) \newline
Skill level of workers \newline
Quality of education in the field\\\hline

Function 7\newline Creation of legitimacy &
Public opinion of the technology \newline
Amount of resistance in regime \newline
Lobbying activities by innovation system members for financial and political support\\\hline
\caption{An overview of indicators for the FIS approach}
\label{tab:2}
\end{tabularx}}

\end{document} 

在此处输入图片描述

答案2

根据 Bernard 的回答,对单元格格式进行了一些小的、题外的改进:

\documentclass[preprint,12pt]{elsarticle}
\usepackage[font=small,labelfont=bf]{caption}% <-- new

\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amssymb}
\usepackage[export]{adjustbox}[2011/08/13]
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{booktabs, ltablex}%
\usepackage{lineno}
\usepackage{color}
\usepackage{url}
\usepackage{ragged2e}
\usepackage{calc}% <-- new
\usepackage{lipsum}%

 \begin{document}
\lipsum[1]
{\setlength\LTleft{-0.1\textwidth}%
 \setlength{\RaggedRightRightskip}{0pt plus 1fil}% <-- new
\begin{tabularx}{1.2\textwidth}{|>{\RaggedRight} p{3.3cm} | X |}
\hline
Function & Indicator \\ \hline
\endhead
Function 1:\newline\smallskip
Entrepreneurial activities 
&   No. of companies
    Size of companies\newline Turnover of companies\newline No. of niche projects or experiments \newline
    No. of companies entering/exiting the innovation system\newline 
    How innovative are 
    they? \\\hline
Function 2:\newline\smallskip 
Knowledge development 
&   \multicolumn{1}{@{}X@{}}{% <-- new
    \begin{tabular}[t]{*{3}{>{\raggedright\arraybackslash}% <-- changed
                         p{(\linewidth-4\tabcolsep-2\arrayrulewidth)/3}|}}
Learning by searching (R\&D)& Learning by doing         & Learning by using\\\hline
No. of patents              & No. of products produced  & No. of users\\\hline
No. of research projects    & No. of niche products     & No. of niche projects\\\hline
No. of scientific papers    & Product quality           & User reviews
    \end{tabular}
                            }\\\hline
Function 3:\newline\smallskip 
Knowledge diffusion through networks 
&   No. of conferences \newline
    No. of seminars \newline
    No. of joint research projects \newline
    Quality of formal and informal contacts between different actors \newline
    Barriers to communication across networks \\\hline
Function 4:\newline\smallskip 
Guidance of the search
&   Goals \newline
    Policy programmes \newline
    Technological best practices and examples \newline
    Ambitious/long terms objectives\\\hline
Function 5:\newline\smallskip
Market formation 
&   Market size \newline
    Market characteristics (niche market or broader) \newline
    Availability of market subsidies \newline
    Motivation for buyers\\\hline
Function 6:\newline\smallskip 
Resources mobilization 
&   No. and kind of financial resources \newline
    No. of physical resources \newline
    No. of human resources (research personnel/skilled labour) \newline
    Skill level of workers \newline
    Quality of education in the field\\\hline
Function 7:\newline\smallskip
Creation of legitimacy 
&   Public opinion of the technology \newline
    Amount of resistance in regime \newline
    Lobbying activities by innovation system members for financial and political support\\\hline
\caption{An overview of indicators for the FIS approach}
\label{tab:2}
\end{tabularx}%
}

在此处输入图片描述

答案3

您不需tabularx要这样做,因为您可以轻松地计算出第二列的宽度。

\documentclass[preprint,12pt]{elsarticle}

\usepackage{graphicx}
\usepackage{geometry}
\usepackage{amssymb}
\usepackage{longtable,array}
\usepackage[export]{adjustbox}[2011/08/13]
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{booktabs}
\usepackage{lineno}
\usepackage{color}
\usepackage{url}

\newlength{\secondcolumn}

\begin{document}

\begingroup
\setlength{\LTleft}{-.1\textwidth}
\setlength{\LTright}{-.1\textwidth}
\setlength{\secondcolumn}{\dimexpr1.2\textwidth-4\tabcolsep-3\arrayrulewidth-4.5cm}
\begin{longtable}{
  |>{\raggedright}m{4.5cm}
  |>{\raggedright\arraybackslash}m{\secondcolumn}|
}
\hline
Function & Indicator \\ \hline
\endhead

Function 1\newline Entrepreneurial\newline activities & 
  No. of companies\newline 
  Size of companies\newline 
  Turnover of companies\newline 
  No. of niche projects or experiments \newline
  No. of companies entering/exiting the innovation system\newline
  How innovative are they?\\\hline\

Function 2\newline Knowledge development & 
\multicolumn{1}{@{}p{\dimexpr\secondcolumn+2\tabcolsep}@{}|}{\begin{tabular}{
  >{\raggedright}p{\dimexpr\hsize/3-2\arrayrulewidth/3-2\tabcolsep}|
  >{\raggedright}p{\dimexpr\hsize/3-2\arrayrulewidth/3-2\tabcolsep}|
  >{\raggedright\arraybackslash}p{\dimexpr\hsize/3-2\arrayrulewidth/3-2\tabcolsep}
}
Learning by searching  (R\&D) & Learning by doing & Learning by using\\\hline
No. of patents & No. of products produced & No. of users\\\hline
No. of research projects & No. of niche products & No. of niche projects\\\hline
No. of scientific papers & Product quality & User reviews\\
\end{tabular}}\\\hline

Function 3\newline Knowledge diffusion through networks & 
No. of conferences \newline
No. of seminars \newline
No. of joint research projects \newline
Quality of formal and informal contacts between different actors \newline
Barriers to communication across networks \\\hline

Function 4\newline Guidance of the search & 
Goals \newline
Policy programmes \newline
Technological best practices and examples \newline
Ambitious/long terms objectives\\\hline

Function 5\newline Market formation & 
Market size \newline
Market characteristics (niche market or broader) \newline
Availability of market subsidies \newline
Motivation for buyers\\\hline

Function 6\newline Resources mobilization & 
No. and kind of financial resources \newline
No. of physical resources \newline
No. of human resources (research personnel/skilled labour) \newline
Skill level of workers \newline
Quality of education in the field\\\hline

Function 7\newline Creation of legitimacy & 
Public opinion of the technology \newline
Amount of resistance in regime \newline
Lobbying activities by innovation system members for financial and political support\\\hline
\caption{An overview of indicators for the FIS approach}
\label{tab:2}
\end{longtable}
\endgroup
\end{document}

答案4

这是您的表格,具有简单的表格环境

\documentclass[preprint,12pt]{elsarticle}
\usepackage{graphicx}
\usepackage[margin=2cm]{geometry}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage[export]{adjustbox}[2011/08/13]
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage{booktabs}
\usepackage{ltablex}
\usepackage{lineno}
\usepackage{color}
\usepackage{url}



\begin{document}

...

\begin{table}[h!]
\centerline{% 
\begin{tabular}{|m{4.5cm}|m{15cm}|}\hline
Function                                                & Indicator \\ \hline
Function 1\newline Entrepreneurial\newline activities   & No. of companies\newline Size of companies\newline Turnover of companies\newline No. of niche projects or experiments \newline No. of companies entering/exiting the innovation system\newline How innovative are they?\\\hline\
Function 2\newline Knowledge development                & 
\begin{tabular}{p{4cm}|p{4cm}|p{3cm}}
Learning by searching  (R\&D) & Learning by doing & Learning by using\\\hline
No. of patents                & No. of products produced & No. of users\\\hline
No. of research projects      & No. of niche products & No. of niche projects\\\hline
No. of scientific papers      & Product quality & User reviews\\
\end{tabular}\\\hline
Function 3\newline Knowledge diffusion through networks & 
No. of conferences \newline
No. of seminars \newline
No. of joint research projects \newline
Quality of formal and informal contacts between different actors \newline
Barriers to communication across networks \\\hline
Function 4\newline Guidance of the search               & 
Goals \newline
Policy programmes \newline
Technological best practices and examples \newline
Ambitious/long terms objectives\\\hline
Function 5\newline Market formation                     & 
Market size \newline
Market characteristics (niche market or broader) \newline
Availability of market subsidies \newline
Motivation for buyers\\\hline
Function 6\newline Resources mobilization               & 
No. and kind of financial resources \newline
No. of physical resources \newline
No. of human resources (research personnel/skilled labour) \newline
Skill level of workers \newline
Quality of education in the field\\\hline
Function 7\newline Creation of legitimacy               & 
Public opinion of the technology \newline
Amount of resistance in regime \newline
Lobbying activities by innovation system members for financial and political support\\\hline
\end{tabular}}
\caption{An overview of indicators for the FIS approach}
\label{tab:2}
\end{table}
\end{document}

相关内容