3

I'm trying to use \tabular but the table I'm getting has the top rows at different heights and I get a weird gap on the right side. Please help?

\begin{center}
\begin{tabular}{ |c|c| } 
 \hline
  & \textbf{Power output loss per year}&\textbf{Type of solar cell}\\ 
  \hline
 Amorphous silicon (a-Si)  & 0.87\\ 
 \hline
 Cadmium telluride (CdTe)  & 0.4\\ 
 \hline
 Copper indium gallium selenide (CIGS) & 0.96\\
 \hline
 Monocrystalline silicon (mono-Si) & 0.36\\
 \hline
 Polycrystalline silicon (poly-Si) & 0.64\\
 \hline

\end{tabular}
\end{center}

2 Answers 2

5

The following MWE contains the corrected code for your table:

\documentclass{article}
\begin{document}

\begin{center}
\begin{tabular}{ |c|c| } 
\hline
 \textbf{Type of solar cell} & \textbf{Power output loss per year}\\ 
 \hline 
 Amorphous silicon (a-Si) & 0.87\\ 
 \hline 
 Cadmium telluride (CdTe) & 0.4\\
 \hline 
 Copper indium gallium selenide (CIGS) & 0.96\\ 
 \hline 
 Monocrystalline silicon (mono-Si) & 0.36\\ 
 \hline 
 Polycrystalline silicon (poly-Si) & 0.64\\
 \hline
\end{tabular}
\end{center} 
\end{document}

Please note, that I would not recommend using that many horizonal and vertical lines to separate the cells. Instead, you could use tables like in the following MWE:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{cc} 
 \textbf{Type of solar cell} & \textbf{Power output loss per year}\\
 \toprule 
 Amorphous silicon (a-Si) & 0.87\\ 
 Cadmium telluride (CdTe) & 0.4\\
 Copper indium gallium selenide (CIGS) & 0.96\\ 
 Monocrystalline silicon (mono-Si) & 0.36\\ 
 Polycrystalline silicon (poly-Si) & 0.64\\
\end{tabular} 
\end{document}

The following image compares both outputs: enter image description here

5

Here are two more possibilities of improvement:

\documentclass{article}
\usepackage[table, svgnames]{xcolor}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize\bfseries}


\begin{document}

\begin{table}[!htb]
  \caption{Some caption}
  \label{solar}
  \sisetup{table-format = 1.2, table-number-alignment = center}
  \setcellgapes{2pt}\makegapedcells
  \centering
  \begin{tabular}{lS}
    \toprule
    \thead{Type of solar cell} & {\thead{Power output loss \\ per year}}\\
    \midrule
    Amorphous silicon (a-Si) & 0.87 \\
    Cadmium telluride (CdTe) & 0.4 \\
    Copper indium gallium selenide (CIGS) & 0.96 \\
    Monocrystalline silicon (mono-Si) & 0.36 \\
    Polycrystalline silicon (poly-Si) & 0.64 \\
    \bottomrule
  \end{tabular}
\end{table}

\begin{table}[!htb]
  \caption{Some caption}
  \label{solar}
  \sisetup{table-format = 1.2, table-number-alignment = center}
  \setlength{\extrarowheight}{2pt}
  \centering
  \rowcolors{1}{white}{Gainsboro!60}
  \begin{tabular}{lS}
    \toprule
    \thead{Type of solar cell} & {\thead{Power output loss \\ per year}}\\
    \specialrule{\lightrulewidth}{\aboverulesep}{0pt}
    Amorphous silicon (a-Si) & 0.87 \\
    Cadmium telluride (CdTe) & 0.4 \\
    Copper indium gallium selenide (CIGS) & 0.96 \\
    Monocrystalline silicon (mono-Si) & 0.36 \\
    Polycrystalline silicon (poly-Si) & 0.64 \\
    \specialrule{\heavyrulewidth}{0pt}{0pt}
  \end{tabular}
\end{table}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .