2

I need a table with blank lines for my Lab reports, If I write a normal table I get lines that are too small, I searched the internet and what I found was a table here with the following code ( slightly altered ): ( Need Horizontal spacing )

\documentclass{article}
\usepackage{tabularx}
\usepackage{geometry}
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}

\begin{document}

\begin{center}
\begin{tabularx}{\textwidth}{@{\rule[-4ex]{0pt}{7ex}}|*{12}{C|}}
\hline
\Delta d (cm) & 0 & 0.5 & 1 & 1.5 & 2 & 2.5 & 3 & 3.5 & 4 & 4.5 & 5 \\
\hline
y_R & & & & & & & & & & \\
\Delta ( \Delta d ) (mm) & & & & & & & & & & \\ [0.5ex]
\hline \hline
\Delta d (cm ) & 5.5 & 6 & 6.5 & 7 & 7.5 & 8 & 8.5 & 9 & 9.5 & 10\\
\hline
y_R & & & & & & & & & & \\
\hline
\Delta ( \Delta d ) (mm) & & & & & & & & & &\\ [0.5 ex]
\hline \hline
\Delta d (cm) & 10.5 & 11 & 11.5 & 12 &12.5 & 13 & 13.5 & 14 & 14.5\\
y_R & & & & & & & & & & \\
\Delta ( \Delta d ) (mm) & & & & & & & & & &\\
\hline
\end{tabularx}
\end{center}
\end{document}

Three points on this one :

  • If I don't use the center environment more than half the table will get out of the page
  • No lines in between the rows
  • The last lines are half blank

I use ShareLatex at the moment, so don't know if it can do any bad, Local Tex editor makes my equations go crazy.

EDIT: Issue Fixed, the last lines being half blank was due to the table being wider than the maximum ( I thought it would just reduce it ) But apparently due to the code I found, the width is set, and overrid Latex's compiler. reducing the table's collumns number to 11 fixed it. Though the extra table that contains the other values is ugly. And if I reduce the table size more I will have to make 4 tables, which is not very pretty.

  • Have you tried the array package and its option to increase spacing (arraystretch)? – TeXnician Feb 6 '17 at 9:16
  • Should've made it more clear, The issue is the horizontal spacing rather than the vertical spacing. arraystretch works on Vertical spacing if I'm not mistaken. – zivo Feb 6 '17 at 9:31
  • Okay, I was not aware that your question refers to the horizontal space. Good you edited it. – TeXnician Feb 6 '17 at 9:32
  • Another question: Why don't you use a fixed-width (p) column type to make the horizontal spacing match your needs? – TeXnician Feb 6 '17 at 9:34
  • Are you, basically, asking how to make the first column wider? – Mico Feb 6 '17 at 9:43
3

It's not clear what is your problem, however your number of ampersands are n many rows to small. Also suggest to remove math environments from column definition and locally set math if it is necessary. After this changes I obtain:

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}

\begin{center}
\begin{tabularx}{\textwidth}{@{\rule[-4ex]{0pt}{7ex}} |*{12}{C|}}
\hline
$\Delta d$ (cm)
        & 0   & 0.5 & 1  & 1.5 & 2   & 2.5 & 3  & 3.5 & 4    & 4.5 & 5  \\
\hline
$y_R$   &     &     &    &     &     &     &     &     &     &     &    \\
$\Delta$ $(\Delta d)$ (mm) 
        &     &     &    &     &     &     &     &     &     &     &    \\ [0.5ex]
\hline \hline
$\Delta d$ (cm) 
        & 5.5 & 6   & 6.5 & 7  & 7.5 & 8   & 8.5 & 9   & 9.5 & 10  &    \\
\hline
$y_R$   &     &     &     &    &     &     &     &      &    &     &    \\
\hline
$\Delta$ $(\Delta d)$ (mm) 
        &     &     &     &    &     &     &     &      &     &    &    \\ [0.5 ex]
\hline \hline
$\Delta d$ (cm) 
        & 10.5& 11  & 11.5& 12 &12.5 & 13  & 13.5& 14   & 14.5&    &    \\
$y_R$   &     &     &     &    &     &     &     &      &     &    &    \\
$\Delta$ $(\Delta d)$ (mm) 
        &     &     &     &    &     &     &     &      &     &    &    \\
\hline
\end{tabularx}
\end{center}
\end{document}

Alternatively, if you like to have first column wider, replace the first C with l:

\begin{tabularx}{\textwidth}{@{\rule[-4ex]{0pt}{7ex}} |l|*{11}{C|}}

And you will obtain:

enter image description here

  • +1 for the use of \rule! – CarLaTeX Feb 7 '17 at 4:39

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.