3

Hi the vertical lines of the table (of the right side) are missing (photo below). I would like to know what's wrong with my code:

\begin{table*}[t]
\centering
 \begin{tabular}{|c c c|} 
 \hline \\
 Comparison & Data-based & Model-based  \\~\\ 
 \hline\hline
 \\
 Complexity & Requires a fair amount of data & Requires a physical model of the system.  \\~\\ 
 \hline
\\
 Fault detection & Diagnosis based on the difference between sensor  & Diagnosis based on output   residual of system \\
  & output under fault-free and faulty cases & model and actual system   \\~\\
 \hline
\\
 Fault model & Fault features discovered based on collected & Through structural analysis, signature matrix  \\
  & data from faulty scenarios. & is generated. \\~\\
 \hline
\\
 Sensor fault & Since the data for this method is collected from sensors, & Can be detected through residuals. \\
  & sensor faults are more difficult to be detected. &   \\~\\  
 \hline
\end{tabular}
\caption{Comparison of data-based and model-based diagnosis method.}
\end{table*}

enter image description here

  • 2
    Welcome to TeX SX! For each empty row, add &&. However, it would simpler to use the cellspace package to add vertical padding to the rows. You should take a look at its documentation. – Bernard May 27 at 9:44
0

You possibly want the top realization; the problem is that your “empty rows” don't get to the last cell: add && to that purpose.

I reduced somewhat the amount, as a full line is really too much.

Consider, though, to use the second example.

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\begin{table*}[t]
\centering

\begin{tabularx}{\textwidth}{|l >{\raggedright}X >{\raggedright\arraybackslash}X|}
\hline
Comparison & Data-based & Model-based \\
\hline\hline
&& \\[-1ex]
Complexity &
  Requires a fair amount of data
  &
  Requires a physical model of the system.
\\[-1ex] && \\
\hline
&& \\[-1ex]
Fault detection &
  Diagnosis based on the difference between sensor output under fault-free and faulty cases
  &
  Diagnosis based on output residual of system model and actual system
\\[-1ex] && \\
\hline
&& \\[-1ex]
Fault model &
  Fault features discovered based on collected data from faulty scenarios.
  &
  Through structural analysis, signature matrix is generated.
\\[-1ex] && \\
\hline
&& \\[-1ex]
Sensor fault &
  Since the data for this method is collected from sensors, 
  sensor faults are more difficult to be detected.
  &
  Can be detected through residuals.
\\[-1ex] && \\
\hline
\end{tabularx}

\caption{Comparison of data-based and model-based diagnosis method.}
\end{table*}

\begin{table*}[t]
\centering

\begin{tabularx}{\textwidth}{l >{\raggedright}X >{\raggedright\arraybackslash}X}
\toprule
Comparison & Data-based & Model-based \\
\midrule
Complexity &
  Requires a fair amount of data
  &
  Requires a physical model of the system.
\\ \addlinespace
Fault detection &
  Diagnosis based on the difference between sensor output under fault-free and faulty cases
  &
  Diagnosis based on output residual of system model and actual system
\\ \addlinespace
Fault model &
  Fault features discovered based on collected data from faulty scenarios.
  &
  Through structural analysis, signature matrix is generated.
\\ \addlinespace
Sensor fault &
  Since the data for this method is collected from sensors, 
  sensor faults are more difficult to be detected.
  &
  Can be detected through residuals.
\\
\bottomrule
\end{tabularx}

\caption{Comparison of data-based and model-based diagnosis method.}
\end{table*}

\end{document}

enter image description here

1

I would like to recommend that you get rid of all vertical lines and most horizontal lines in the table; whitespace can be every bit as good as a straight line for providing visual separation. And, use the tabularx environment to allow automatic line wrapping in the cells.

enter image description here

Does anyone really think that this table would look markedly better if it featured vertical lines and/or three additional horizontal lines?


\documentclass{article}
\usepackage[margin=1in,a4paper]{geometry} % choose suitable page parameters
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\begin{document}

\begin{table*}[t]
 \begin{tabularx}{\textwidth}{@{} lLL @{}}
\toprule
 Comparison & Data-based & Model-based\\
\midrule
 Complexity 
 & Requires a fair amount of data 
 & Requires a physical model of the system\\
\addlinespace
 Fault detection 
 & Diagnosis based on the difference between sensor output under fault-free and faulty cases
 & Diagnosis based on output residual of system model and actual system\\
\addlinespace
 Fault model 
 & Fault features discovered based on collected data from faulty scenarios
 & Through structural analysis, signature matrix is generated\\
\addlinespace
 Sensor fault 
 & Since the data for this method is collected from sensors, sensor faults are more difficult to be detected
 & Can be detected through residuals \\
\bottomrule
\end{tabularx}
\caption{Comparison of data-based and model-based diagnosis methods.}
\end{table*}
\end{document} 
0

Output

\documentclass[10pt]{article}
\usepackage[letterpaper]{geometry}
\usepackage{showframe}

% An entry has a fixed size of 5cm (unless the size is passed as an argument using [<length>]).
\newcommand{\entry}[2][5cm]{\parbox{#1}{\vspace{1em}\centering #2\vspace{1em}}}

\begin{document}
    \begin{table*}[h]
        \centering
        \begin{tabular}{|ccc|}\hline
            % Row 1 (Header)
            \entry[2.5cm]{Comparison} & % cell 1
            \entry[2.5cm]{Data-based} & % cell 2
            \entry[2.5cm]{Model-based}  % cell 3
            \\\hline\hline
            % Row 2
            \entry[2.5cm]{Complexity} &                         % cell 1
            \entry{Requires a fair amount of data} &            % cell 2
            \entry{Requires a physical model of the system.}    % cell 3
            \\\hline
            % Row 3
            \entry[2.5cm]{Fault detection} &                        % cell 1
            \entry{Diagnosis based on the difference between sensor
                   output under fault-free and faulty cases} &      % cell 2
            \entry{Diagnosis based on output residual of system
                   model and actual system}                         % cell 3
            \\\hline
            % Row 4
            \entry[2.5cm]{Fault model} &                            % cell 1
            \entry{Fault features discovered based on collected
                   data from faulty scenarios} &                    % cell 2
            \entry{Through structural analysis, signature matrix
                   is generated}                                    % cell 3
            \\\hline
            % Row 5
            \entry[2.5cm]{Sensor fault} &                                   % cell 1
            \entry{Since the data for this method is collected from sensors,
                   sensor faults are more difficult to be detected} &       % cell 2
            \entry{Can be detected through residuals}                       % cell 3
            \\\hline
        \end{tabular}
    \end{table*}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.