\newcolumntype 弄乱了我的其他列

\newcolumntype 弄乱了我的其他列

我想将文本垂直对齐第 1、3、4、5 和 6 列的中间。我已经尝试使用m{2cm},但它不起作用。

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{adjustbox}
\usepackage{array,ragged2e}
\usepackage{multirow}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\begin{document}

\begin{table*}[!ht]
    \centering
    \caption{A survey of an energy optimized smart systems. }
    \begin{adjustbox}{width=\textwidth}
    \begin{tabular}{|c|P {2.5 cm}|P {2 cm}|c|c|c|}

    \hline
        Ref. & \centering{Components} & With Feedback & Individual Energy Consumption Monitoring & Cloud Platform & Cost Effective \\
        \hline
        \cite{Liao2019} & Arduino, PIR sensor, temperature and humidity sensor, particulate matter sensor, gas sensors, LUX sensor, Wi-Fi module & Yes & The energy consumption is not calculated. & ThingSpeak web service & Used low-cost devices\\
        \hline
        \cite{Chooruang2018} & Raspberry Pi, Router, Energy meter, CT (current transformer) sensor, energy measurement chip and ESP8266  & No & Able to calculate & InfluxDB & Used low-cost devices \\
        \hline
        \cite{Esquiagola2018} & Raspberry pi, border router, IAQ sensor node, wireless module
, Sensors: Temperature, Humidity, Pressure, Particulate Material, TVOC and eCO2. & No & No & MariaDB & Used low-cost devices\\
        \hline
        \cite{Jaribion2019} & Sensors: Particulate matter (PM), Air quality, Temperature and Humidity. & Yes & Yes & Local storage & Used low-cost devices\\
        \hline
        \cite{Avancini} & IoT Enabled Smart Energy Meter & No & Yes & Horus NMS & Quite expensive\\
        \hline
        \cite{Ramani2019} & Arduino, ESP8266, Voltage divider, battery, solar panel, optocoupler, inverter, relay, LCD, Energy meter,LDR sensor & Yes & Yes, overall not individually & Not mentioned & Not mentioned\\
        \hline
        \cite{D2017} & GSM Module, LCD, ZigBee Module,PIC micro-controller, Energy Meter & No & Yes, overall not individually & Not mentioned & Used low-cost devices\\
        \hline
        \cite{Dutta2017} & Arduino, Relay, Wi-Fi module, Bluetooth module, Cisco router, RFID reader, Laser, LDR, temperature and humidity sensor, PIR sensor, ultrasonic sensor, gas sensors, air pollution sensor, Flame Sensor & Yes & It is calculated for the whole system instead individually & Via fog cloud & Used low-cost devices \\
        \hline
        \cite{Gunawan2017} & Arduino, relay, ethernet shield, wireless module, gas sensor, temparture sensor, PIR sensor, ultrasonic sensor & No & The energy consumption is not calculated. & Through web app & In the mid-range.\\
        \hline
        \cite{Vivekbabu2017} & Raspberry Pi, analog temperature sensor, analog soil moisture sensor, rain sensor, LDR, temperature and humidty sensor, analog to digital converter, Wi-Fi module, LCD display, router & No & No calculation & sparkfun DB & Low-cost devices\\
        \hline
        \cite{Yuliansyah2019} & ESP8266, LDR, sonar sensor, light intensity sensor, relay, servo motor & Yes & Not calculated &  & Mid-cost devices\\
       % \hline
        %\cite{Shrivastava2020} & & & & &\\
       % \hline
       % \cite{Kim2013} & & & & &\\
        %\hline
        %\cite{Zhang2014} & & & & &\\
        \hline
        \cite{Patchava2015} & Raspberry Pi, GSM Module, Sensors & User controlled & No calculation & MYSQLDB & Quite high-cost devices\\
        \hline
    \end{tabular}
    \end{adjustbox}
    \label{tab:my_label}
\end{table*}
\end{document}

答案1

我建议您放弃adjustbox包装器,从环境切换tabulartabularx环境,允许在第 2 列和第 4 列中进行文本换行/换行,通过摆脱所有垂直规则和大多数水平规则使表格看起来更加开放,最后但同样重要的是,运行\renewcommand\tabularxcolumn[1]{m{#1}}以从顶部对齐切换到单元格内容的垂直居中。

在此处输入图片描述

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularx,booktabs,ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\hsize=#1\hsize}X} % variable-width, left-aligned
\renewcommand\tabularxcolumn[1]{m{#1}} % vertical centering

\begin{document}

\begin{table*}
    \caption{Survey of energy optimized smart systems}
    \label{tab:my_label}

    \begin{tabularx}{\textwidth}{@{} l L{1.25} c L{0.75} l l @{}}
    \toprule
    Ref. & Components & With Feedback & Individual Energy Consumption Monitoring & Cloud Platform & Cost Effective \\
    \midrule
    \cite{Liao2019} & Arduino, PIR sensor, temperature and humidity sensor, particulate matter sensor, gas sensors, LUX sensor, Wi-Fi module & Yes & The energy consumption is not calculated. & ThingSpeak web service & Used low-cost devices\\
    \addlinespace
    \cite{Chooruang2018} & Raspberry Pi, Router, Energy meter, CT (current transformer) sensor, energy measurement chip and ESP8266  & No & Able to calculate & InfluxDB & Used low-cost devices \\
    \addlinespace
    \cite{Esquiagola2018} & Raspberry pi, border router, IAQ sensor node, wireless module. Sensors: Temperature, Humidity, Pressure, Particulate Material, TVOC and eCO2. & No & No & MariaDB & Used low-cost devices\\
    \addlinespace
    \cite{Jaribion2019} & Sensors: Particulate matter (PM), Air quality, Temperature and Humidity. & Yes & Yes & Local storage & Used low-cost devices\\
    \addlinespace
    \cite{Avancini} & IoT Enabled Smart Energy Meter & No & Yes & Horus NMS & Quite expensive\\
    \addlinespace
    \cite{Ramani2019} & Arduino, ESP8266, Voltage divider, battery, solar panel, optocoupler, inverter, relay, LCD, Energy meter,LDR sensor & Yes & Yes, overall not individually & Not mentioned & Not mentioned\\
    \addlinespace
    \cite{D2017} & GSM Module, LCD, ZigBee Module,PIC micro-controller, Energy Meter & No & Yes, overall not individually & Not mentioned & Used low-cost devices\\
    \addlinespace
    \cite{Dutta2017} & Arduino, Relay, Wi-Fi module, Bluetooth module, Cisco router, RFID reader, Laser, LDR, temperature and humidity sensor, PIR sensor, ultrasonic sensor, gas sensors, air pollution sensor, Flame Sensor & Yes & It is calculated for the whole system instead individually & Via fog cloud & Used low-cost devices \\
    \addlinespace
    \cite{Gunawan2017} & Arduino, relay, ethernet shield, wireless module, gas sensor, temparture sensor, PIR sensor, ultrasonic sensor & No & The energy consumption is not calculated. & Through web app & In the mid-range.\\
    \addlinespace
    \cite{Vivekbabu2017} & Raspberry Pi, analog temperature sensor, analog soil moisture sensor, rain sensor, LDR, temperature and humidty sensor, analog to digital converter, Wi-Fi module, LCD display, router & No & No calculation & sparkfun DB & Low-cost devices\\
    \addlinespace
    \cite{Yuliansyah2019} & ESP8266, LDR, sonar sensor, light intensity sensor, relay, servo motor & Yes & Not calculated &  & Mid-cost devices\\
    % \hline
    %\cite{Shrivastava2020} & & & & &\\
    % \hline
    % \cite{Kim2013} & & & & &\\
    %\hline
    %\cite{Zhang2014} & & & & &\\
    \addlinespace
    \cite{Patchava2015} & Raspberry Pi, GSM Module, Sensors & User controlled & No calculation & MYSQLDB & Quite high-cost devices\\
    \bottomrule
    \end{tabularx}
\end{table*}
\end{document}

答案2

仅将使用tabularx包的精彩 @Mico 答案 (+1) 转录到使用包的表中tabularray。对于列规范,使用X[..,m](类似于X列,但增加了单元格内容的大小和对齐规范)和Q[...](相当于cl或˙r columns with added aligning specification):. Used\addlinespace are replaced by specification of rows separation (rowsep=3pt m default isrowsep=2pt`。

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularray}

\begin{document}

\begin{table*}
    \caption{Survey of energy optimized smart systems}
    \label{tab:my_label}

    \begin{tblr}{hline{1,2,Z} = 1pt, 
                 colsep=4pt,
                 colspec = {@{} Q[l,m] X[2,l,j,m] Q[c,m] X[l,m] *{2}{Q[l,m]} @{}},
                 rowsep = 3pt}
Ref.    & Components   
            & {With\\ Feedback} & Individual Energy Consumption Monitoring & Cloud Platform & Cost Effective \\
\cite{Liao2019}         
        & Arduino, PIR sensor, temperature and humidity sensor, particulate matter sensor, gas and LUX sensor, Wi-Fi module 
            & Yes & The energy consumption is not calculated. & ThingSpeak web service & Used low-cost devices\\
\cite{Chooruang2018}    
        & Raspberry Pi, Router, Energy meter, CT (current transformer) sensor, energy measurement chip and ESP8266  
            & No  & Able to calculate & InfluxDB & Used low-cost devices \\
\cite{Esquiagola2018}   
        & Raspberry pi, border router, IAQ sensor node, wireless module. Sensors: Temperature, Humidity, Pressure, Particulate Material, TVOC and eCO2. 
            & No    & No & MariaDB & Used low-cost devices\\
\cite{Jaribion2019}     
    & Sensors: Particulate matter (PM), Air quality, Temperature and Humidity. 
        & Yes & Yes & Local storage & Used low-cost devices\\
\cite{Avancini}         
    & IoT Enabled Smart Energy Meter 
        & No & Yes & Horus NMS & Quite expensive\\
\cite{Ramani2019}       
    & Arduino, ESP8266, Voltage divider, battery, solar panel, optocoupler, inverter, relay, LCD, Energy meter, LDR sensor 
        & Yes & Yes, overall not individually & Not mentioned & Not mentioned\\
\cite{D2017}            
    & GSM Module, LCD, ZigBee Module,PIC micro-controller, Energy Meter 
        & No & Yes, overall not individually & Not mentioned & Used low-cost devices\\
\cite{Dutta2017}        
    & Arduino, Relay, Wi-Fi module, Bluetooth module, Cisco router, RFID reader, Laser, LDR, temperature and humidity sensor, PIR sensor, ultrasonic sensor, gas sensors, air pollution sensor, Flame Sensor 
        & Yes & It is calculated for the whole system instead individually & Via fog cloud & Used low-cost devices \\
\cite{Gunawan2017}     
    & Arduino, relay, ethernet shield, wireless module, gas sensor, temparture sensor, PIR sensor, ultrasonic sensor 
        & No  & The energy consumption is not calculated. & Through web app & In the mid-range.\\
\cite{Vivekbabu2017}    
    & Raspberry Pi, analog temperature sensor, analog soil moisture sensor, rain sensor, LDR, temperature and humidity sensor, analog to digital converter, Wi-Fi module, LCD display, router 
        & No    & No calculation & sparkfun DB & Low-cost devices\\
\cite{Yuliansyah2019}   
    & ESP8266, LDR, sonar sensor, light intensity sensor, relay, servo motor 
        & Yes & Not calculated &  & Mid-cost devices\\
    % \hline
    %\cite{Shrivastava2020} & & & & &\\
    % \hline
    % \cite{Kim2013} & & & & &\\
    %\hline
    %\cite{Zhang2014} & & & & &\\
\cite{Patchava2015} 
    & Raspberry Pi, GSM Module, Sensors 
        & {User\\ controlled} & No calculation & MYSQLDB & Quite high-cost devices\\
    \end{tblr}
\end{table*}
\end{document}

在此处输入图片描述

答案3

您可以使用这个tabularray包,它使得处理行和列变得非常容易。

%To make the code compilable with bibliography file without any warning
%Should be omitted in the original document
%---------------------------------------------
\begin{filecontents}{\jobname.bib}
@book{key,
  author = {Author, A.},
  year = {2001},
  title = {Title},
  publisher = {Publisher},
}
\end{filecontents}
%---------------------------------------------

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularray}

\begin{document}
\begin{table*}[htbp]
    \centering
    \caption{A survey of an energy optimized smart systems. }
    \label{tab:my_label}
    \begin{tblr}{
        hlines, vlines,
        width = \textwidth,
        colspec = {X[0.25,c,m] X[1.5,l,m] X[0.5,c,m] X[1.25,l,m] X[c,m] X[c,m]},
    }
        Ref. & \centering{Components} & With Feedback & Individual Energy Consumption Monitoring & Cloud Platform & Cost Effective \\
        
        \cite{key} & Arduino, PIR sensor, temperature and humidity sensor, particulate matter sensor, gas sensors, LUX sensor, Wi-Fi module & Yes & The energy consumption is not calculated. & ThingSpeak web service & Used low-cost devices\\
        
        \cite{key} & Raspberry Pi, Router, Energy meter, CT (current transformer) sensor, energy measurement chip and ESP8266  & No & Able to calculate & InfluxDB & Used low-cost devices \\
        
        \cite{key} & Raspberry pi, border router, IAQ sensor node, wireless module
, Sensors: Temperature, Humidity, Pressure, Particulate Material, TVOC and eCO2. & No & No & MariaDB & Used low-cost devices\\
        
        \cite{key} & Sensors: Particulate matter (PM), Air quality, Temperature and Humidity. & Yes & Yes & Local storage & Used low-cost devices\\
        
        \cite{key} & IoT Enabled Smart Energy Meter & No & Yes & Horus NMS & Quite expensive\\
        
        \cite{key} & Arduino, ESP8266, Voltage divider, battery, solar panel, optocoupler, inverter, relay, LCD, Energy meter,LDR sensor & Yes & Yes, overall not individually & Not mentioned & Not mentioned\\
        
        \cite{key} & GSM Module, LCD, ZigBee Module,PIC micro-controller, Energy Meter & No & Yes, overall not individually & Not mentioned & Used low-cost devices\\
        
        \cite{key} & Arduino, Relay, Wi-Fi module, Bluetooth module, Cisco router, RFID reader, Laser, LDR, temperature and humidity sensor, PIR sensor, ultrasonic sensor, gas sensors, air pollution sensor, Flame Sensor & Yes & It is calculated for the whole system instead individually & Via fog cloud & Used low-cost devices \\
        
        \cite{key} & Arduino, relay, ethernet shield, wireless module, gas sensor, temparture sensor, PIR sensor, ultrasonic sensor & No & The energy consumption is not calculated. & Through web app & In the mid-range.\\
        
        \cite{key} & Raspberry Pi, analog temperature sensor, analog soil moisture sensor, rain sensor, LDR, temperature and humidty sensor, analog to digital converter, Wi-Fi module, LCD display, router & No & No calculation & sparkfun DB & Low-cost devices\\
        
        \cite{key} & ESP8266, LDR, sonar sensor, light intensity sensor, relay, servo motor & Yes & Not calculated &  & Mid-cost devices\\
       % 
        %\cite{Shrivastava2020} & & & & &\\
       % 
       % \cite{Kim2013} & & & & &\\
        %
        %\cite{Zhang2014} & & & & &\\
        
        \cite{key} & Raspberry Pi, GSM Module, Sensors & User controlled & No calculation & MYSQLDB & Quite high-cost devices\\
    \end{tblr}
\end{table*}

\bibliographystyle{IEEEtran} %usual style used by IEEE articles
\bibliography{\jobname}
\end{document}

在此处输入图片描述

该选项hlines用于在每行周围插入水平线,以及vlines在每列周围插入垂直线。width指定整个表格的宽度,colspec用于指定列类型。

答案4

正确的定义是

\newcolumntype{P}[1]{>{\centering\arraybackslash}m{#1}}

输出为

输出居中列

相关内容