使用 tabularx 环境控制表格中的单元格宽度

使用 tabularx 环境控制表格中的单元格宽度

在此处输入图片描述

MWE 生成表格,但我打算执行以下操作:1) 我尝试在第 3 列和第 4 列中添加文本,但如果在第 3 列中添加更多文本,它也会增加第 2 列单元格的大小,有人可以指导我如何遇到此问题吗?为了便于理解,我还分享了一个示例格式,说明我正在编写的内容。请在下面查看。 在此处输入图片描述

\begin{table*}
\centering
\caption{A  model}
\setcellgapes{3pt}
\makegapedcells
\footnotesize
\setlength\tabcolsep{2pt}
\begin{tabularx}{\textwidth}{|p{12mm}|>{\hsize=0.9\hsize}X|
                                      >{\hsize=1.2\hsize}X|
                                      >{\hsize=0.9\hsize}X|}
    \hline
\thead{Ref. no(s)}  & \thead{Used} & \thead{adjective} &   \thead{yield} \\
    \hline
\cite{9}            
                    &Reduces the required computational cost 

                        & \multirow{5}{=}{This pricing scheme refers to a list of price plans for different products or services, which come along with differentiated
quantities or qualities [17]. It can ensure that the pricing entity
(LSE in this paper) can lead the formulation of price, while
providing consumers with more flexible price plans. As shown
in Fig. 2, the main procedure includes:
1) LSE notifies the required load adjustment signals.
2) The i-th CL voluntarily provides information at time t
including price bids (price asked for) θ+
di,t
, θ−
di,t
, upper bounds
of load adjustment P¯ +
di,t
, P¯ −
di,t and elasticity coefficient εdi.
Here + denotes load increase, − denotes load decrease. The
load adjustment at time t is related to not only the price at
time t, but also the price at other times [18]. The elasticity coefficient εdi is a vector including the self-elasticity and
cross-elasticity, i.e.,}  &Research and development in flywheel, compressed air, thermal (molten salts), and hydrogen storage systems are making great progress. In addition to physical storage devices, great potential lies in the exploitation of end-use side energy storage for the grid. For example, energy-demand management of water heaters and air-conditioning cycling utilizes the thermal energy stored in water tanks and buildings at consumer premises in exchange for electricity. Smart vehicle charging and discharging (or vehicle-to-grid, V2G) technology utilizes electrochemical energy stored in the batteries of EVs/PHEVs to act as energy storage for the grid. These “virtual energy-storage systems,” when properly managed in the future grid, can provide a large quantity of cost-efficient power in both directions to the grid.   \\
 \cline{1-2}
\cite{03}           & Minimizes the computational cost and time period
                         &   &   \\
\cline{1-2}
 \cite{14,15}       & Achieving least value to scale up the solution
                        &   &   \\
\hline
Designed model      &  In this paper, a relatively new yet superior clustering algorithm based on density peak, proposed by Rodriguez and Laio,
is introduced and employed & \multirow{5}{=}{According to the clustering features of the CLs’ historical information, LSE can divide CLs into K+ types of load
increase and K− types of load decrease. Moreover, when the
market for DR participants is immature, not all of consumers
will bid voluntarily. In that case, LSE has to forecast the cost
function of load adjustment of consumers based on the historical data. Alternatively, the cost function could be reflected
by other market signals such as reserve service (or frequency
regulation) prices or value of customer reliability.
3)}  &  From Smart Grid to Internet of Energy covers novel and emerging metering and monitoring technologies, communication systems, and technologies in smart grid areas to present a valuable reference for readers from various engineering backgrounds. Considering relevant topics on the essentials of smart grids and emerging wireless communication systems, such as IEEE 802.15.4 based novel technologies, cognitive radio networks and Internet of Energy, this book offers a discussion on the emerging trends and research direction for communication technologies. The book includes research concepts and visualization of smart grids and related communication technologies, making it a useful book for practicing network engineers. \\   \hline
\end{tabularx}
    \end{table*}

答案1

由于没有给出 MWE,我不得不猜测文档类和包:

在此处输入图片描述

\documentclass{article} %% guesed because no MWE was given
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{multirow}

\usepackage{geometry} %% guesed because no MWE was given
\begin{document}

\begin{table*}
\centering
\caption{A  model}
\setcellgapes{3pt}
\makegapedcells
\footnotesize
\setlength\tabcolsep{2pt}
\begin{tabularx}{\textwidth}{|p{12mm}|>{\raggedright\arraybackslash}p{1.75cm}|X|X|}
    \hline
{Ref. no(s)}  & \thead{Used} & \thead{adjective} &   \thead{yield} \\
    \hline
\cite{9}            
                    &Reduces the required computational cost \newline \newline 

                        & \multirow{20}{=}{This pricing scheme refers to a list of price plans for different products or services, which come along with differentiated
quantities or qualities [17]. It can ensure that the pricing entity
(LSE in this paper) can lead the formulation of price, while
providing consumers with more flexible price plans. As shown
in Fig. 2, the main procedure includes:
1) LSE notifies the required load adjustment signals.
2) The i-th CL voluntarily provides information at time t
including price bids (price asked for) θ+
di,t
, θ−
di,t
, upper bounds
of load adjustment P¯ +
di,t
, P¯ −
di,t and elasticity coefficient εdi.
Here + denotes load increase, − denotes load decrease. The
load adjustment at time t is related to not only the price at
time t, but also the price at other times [18]. The elasticity coefficient εdi is a vector including the self-elasticity and
cross-elasticity, i.e.,}  & \multirow{17}{=}{Research and development in flywheel, compressed air, thermal (molten salts), and hydrogen storage systems are making great progress. In addition to physical storage devices, great potential lies in the exploitation of end-use side energy storage for the grid. For example, energy-demand management of water heaters and air-conditioning cycling utilizes the thermal energy stored in water tanks and buildings at consumer premises in exchange for electricity. Smart vehicle charging and discharging (or vehicle-to-grid, V2G) technology utilizes electrochemical energy stored in the batteries of EVs/PHEVs to act as energy storage for the grid. These “virtual energy-storage systems,” when properly managed in the future grid, can provide a large quantity of cost-efficient power in both directions to the grid.}   \\
 \cline{1-2}
\cite{03}           & Minimizes the computational cost and time period \newline \newline
                         &   &   \\
\cline{1-2}
 \cite{14,15}       & Achieving least value to scale up the solution \newline \newline 
                        &   &   \\
\hline
Designed model      &  In this paper, a relatively new yet superior clustering algorithm based on density peak, proposed by Rodriguez and Laio,
is introduced and employed & \multirow{5}{=}{According to the clustering features of the CLs’ historical information, LSE can divide CLs into K+ types of load
increase and K− types of load decrease. Moreover, when the
market for DR participants is immature, not all of consumers
will bid voluntarily. In that case, LSE has to forecast the cost
function of load adjustment of consumers based on the historical data. Alternatively, the cost function could be reflected
by other market signals such as reserve service (or frequency
regulation) prices or value of customer reliability.
3)}  &  From Smart Grid to Internet of Energy covers novel and emerging metering and monitoring technologies, communication systems, and technologies in smart grid areas to present a valuable reference for readers from various engineering backgrounds. Considering relevant topics on the essentials of smart grids and emerging wireless communication systems, such as IEEE 802.15.4 based novel technologies, cognitive radio networks and Internet of Energy, this book offers a discussion on the emerging trends and research direction for communication technologies. The book includes research concepts and visualization of smart grids and related communication technologies, making it a useful book for practicing network engineers. \\   \hline
\end{tabularx}
    \end{table*}

    \end{document}

答案2

作为@Leandriis 答案(+1)的补充,文本格式(使用microtypeenumitemcaption包,multirow在最后一行删除等)和转换代码有(非常)小的变化,以形成可与pdfLaTeX引擎编译的形式:

\documentclass[twocolumn]{article}
\usepackage{geometry}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\bfseries\footnotesize}
\usepackage{microtype}        % new
\usepackage{enumitem}         % new
\usepackage[skip=1ex]{caption}% new

\begin{document}

\begin{table*}
\centering
\caption{A  model}
\setcellgapes{3pt}
\makegapedcells
\footnotesize
\setlength\tabcolsep{3pt}
\begin{tabularx}{\textwidth}{|p{12mm}|>{\raggedright}p{16mm}|X|X|}
    \hline
\thead{Ref.\\ no(s)}  & \thead{Used} & \thead{adjective} &   \thead{yield} \\
    \hline
\cite{9}
    &   Reduces the required computational cost 
        &   \multirow{22}{=}{This pricing scheme refers to a list of price plans for different products or services, which come along with differentiated quantities or qualities \cite{17}. It can ensure that the pricing entity (LSE in this paper) can lead the formulation of price, while providing consumers with more flexible price plans. As shown in Fig. 2, the main procedure includes:
                \begin{enumerate}[nosep, leftmargin=*, label=\bfseries\arabic*.]
            \item   LSE notifies the required load adjustment signals.
            \item   The $i$-th CL voluntarily provides information at time $t$ price bids (price asked for)
            $\theta+\frac{di}{dt}, \theta-\frac{di}{dt}$,
                bounds of load adjustment
                $\bar{P}+\frac{di}{dt},\bar{P}-\frac{di}{dt}$
                and elasticity coefficient $\varepsilon di$.
                \end{enumerate}
            Here $+$ denotes load increase, $-$ denotes load decrease. The load adjustment at time $t$ is related to not only the price at time $t$, but also the price at other times \cite{18}. The elasticity coefficient $\varepsilon di$ is a vector including the self-elasticity and cross-elasticity, i.e., \dots}
                &      \multirow{20}{=}{Research and development in flywheel, compressed air, thermal (molten salts), and hydrogen storage systems are making great progress. In addition to physical storage devices, great potential lies in the exploitation of end-use side energy storage for the grid. For example, energy-demand management of water heaters and air-conditioning cycling utilizes the thermal energy stored in water tanks and buildings at consumer premises in exchange for electricity. Smart vehicle charging and discharging (or vehicle-to-grid, V2G) technology utilizes electrochemical energy stored in the batteries of EVs/PHEVs to act as energy storage for the grid. These ''virtual energy-storage systems,'' when properly managed in the future grid, can provide a large quantity of cost-efficient power in both directions to the grid.}           \\
%    \cline{1-2}
\cite{03}
    &   Minimizes the computational cost and time period
        &   &       \\
%\cline{1-2}
 \cite{14,15}
    &   Achieving least value to scale up the solution 
        \vspace{8\baselineskip} % added vertical space that multirow cell's content 
                                % doesn't protrude into the row below it
        &   &       \\
\hline
Designed model
    &  In this paper, a relatively new yet superior clustering algorithm based on density peak, proposed by Rodriguez and Laio, is introduced and employed
        &   According to the clustering features of the CLs’ historical information, LSE can divide CLs into $K^+$ types of load increase and $K^-$ types of load decrease. Moreover, when the market for DR participants is immature, not all of consumers will bid voluntarily. In that case, LSE has to forecast the cost function of load adjustment of consumers based on the historical data. Alternatively, the cost function could be reflected by other market signals such as reserve service (or frequency regulation) prices or value of customer reliability. \dots 
            &   From Smart Grid to Internet of Energy covers novel and emerging metering and monitoring technologies, communication systems, and technologies in smart grid areas to present a valuable reference for readers from various engineering backgrounds. Considering relevant topics on the essentials of smart grids and emerging wireless communication systems, such as IEEE 802.15.4 based novel technologies, cognitive radio networks and Internet of Energy, this book offers a discussion on the emerging trends and research direction for communication technologies. The book includes research concepts and visualization of smart grids and related communication technologies, making it a useful book for practicing network engineers.   \\
    \hline
\end{tabularx}
    \end{table*}
\end{document}

在此处输入图片描述

答案3

我尝试了一种“解决”问题的方法。这不是最终的解决方案……我们需要有人对此有更多了解,并给出答案。

table特别是,我在使用和环境方面遇到了很多问题figure。每当我需要这些元素时,我都会minipage根据需要使用其中一个包来处理图形、表格计数和“列表”:caption或者capt-of如果我不使用memoir类。如果memoir是所使用的类,它有自己的命令来执行此操作(例如\newfixedcaption,回忆录文档第 195 页)。

因此,为了获得此输出,我使用captionchangepage(使用adjustwidth环境以集中tabularx)。其他修改是在\hline。我不知道为什么当我更改长度时它太短了。但是,使用\cline{1-4}(在这种情况下为 4,因为总列数),它可以工作。

其他更改是在列的类型上。我创建了一个newtypecolumn名为的H,它是一种p类型。

必须更改文本... 在这里我遇到了字符编译问题。因此,我创建了一个“lorem ipsum”文本来尝试。现在,使用此代码和您的文本进行尝试。

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{array}

\usepackage{caption} %to use \captionof
\usepackage{changepage} %to use adjustwidth

\newcolumntype{H}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}

\begin{center}
\captionof{table}{A  model}
\setcellgapes{3pt}
\makegapedcells
\footnotesize
\setlength\tabcolsep{2pt}
\begin{adjustwidth}{-1.5cm}{}
\begin{tabularx}{\linewidth}{|p{15mm}|H{3cm}|H{6cm}|H{6cm}|}
\cline{1-4}
\thead{Ref. no(s)}  & \thead{Used} & \thead{adjective} &   \thead{yield} \\
\cline{1-4}
\cite{9}            
                    &Reduces the required computational cost 

                        & \multirow{5}{=}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc.}  & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo.   \\
\cline{1-2}
\cite{03}           & Minimizes the computational cost and time period
                         &   &   \\
\cline{1-2}
\cite{14,15}       & Achieving least value to scale up the solution
                        &   &   \\
\cline{1-4}
Designed model      &  In this paper, a relatively new yet superior clustering algorithm based on density peak, proposed by Rodriguez and Laio, is introduced and employed & \multirow{5}{=}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc.}  & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc.  \\
\cline{1-4}
\end{tabularx}
\end{adjustwidth}
\end{center}

\end{document}

相关内容