-1

I get a solution in https://tex.stackexchange.com/a/42186/128718 where he gave a solution to create attendance sheet in LaTeX. His solution is good.

But,he put column's width and title in separate line. When I have many columns and need to change the column's width again and again to adjust it with expected looks, I have to search the p{width} for that column that is boring and time consuming.

So, if there is a way that allow to put the width alongside the column's title it is easy to change any column's width.(e.g. column{|Name}{width=2cm})

You can give any solution to create attendance sheet/other table with the expected feature.

alhelal
  • 2,451

2 Answers2

1

This uses \makebox to combine the width and title in one step. It does not check to make sure the title will fit in the space requested. Once could also use \parbox.

I started playing around with the loop to add lines, discovered it was harder than I thought, then decided it wasn't worth the effort.

\documentclass{article}
\begin{document}

\def\arraystretch{2.5}% vertical spacing in multiples of \strut
\def\aline{&&&&\\\hline}% number of & = number of columns-1
\noindent\begin{tabular}{|l|l|l|l|l|}
\hline
\makebox[2cm][l]{Name}& 
\makebox[2cm][l]{Item}& 
\makebox[2cm][l]{Pickup}& 
\makebox[2cm][l]{Return}& 
\makebox[2cm][l]{Signature}\\\hline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\aline
\end{tabular}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
0

One possibility is to eliminate the left and right cell margins using @{} in the column definition:

\begin{tabular}{|@{}l@{}|@{}l@{}|@{}l@{}|@{}l@{}|@{}l@{}|}

Then for your header row you can overlap the header names (using \rlap) with a horizontal space of the width you desire:

\rlap{ Name}\hspace{2cm} & \rlap{ Item}\hspace{3cm} & \rlap{ Pickup}\hspace{2cm} & \rlap{ Return}\hspace{2cm} & \rlap{ Signature}\hspace{3cm}

Another possibility is to insert comments into your column definitions. You could define a macro:

\newcommand{\xx}[1]{}

that does nothing. So \xx{stuff} will basically just turn stuff into a comment. Your code would look like this:

\begin{tabular}{|p{2cm}\xx{name}|p{3cm}\xx{item}|p{2cm}\xx{pickup}|p{2cm}\xx{return}|p{3cm}\xx{sign}|}
Sandy G
  • 42,558