5

I use tabulary package for automatic width adjustment, but I have a blank line in the first row.

enter image description here

\documentclass{article} \usepackage{tabulary} \begin{document} \begin{table}[htbp] \begin{tabulary}{1.0\textwidth}{L|L|L|L|L} \hline & \hbox{Name} & \hbox{Function} & \hbox{Properties} & \hbox{Relationships} \\\hline\hline 7 & \hbox{System Maintenance Database} & Stores all kinds of errors occurred during operation from all components in a specified way & Only error related information is stored & \\ 9 & Main Database & & \\ \hline \end{tabulary} \caption{Data elements} \label{data} \end{table} \end{document} 

What's wrong? How do I remove it?

1
  • \hbox is not documented in the LaTeX manual and for a reason: its behavior can be surprising. But why do you think you need it? Commented Oct 26, 2013 at 19:39

2 Answers 2

3

You are trying to change the format of certain cells by using \hbox. The correct way to do this is to use \multicolumn:

Sample output

\documentclass{article} \usepackage{tabulary} \begin{document} \begin{table}[htbp] \begin{tabulary}{0.9\textwidth}{L|L|L|L|L} \hline &\multicolumn{1}{l|}{Name}&\multicolumn{1}{l|}{Function} &\multicolumn{1}{l|}{Properties}&\multicolumn{1}{l}{Relationships}\\ \hline\hline 7 &System Maintenance Database &Stores all kinds of errors occurred during operation from all components in a specified way & Only error related information is stored & \\ 9 & Main Database & & \\ \hline \end{tabulary} \caption{Data elements} \label{data} \end{table} \end{document} 

I have unboxed your "System Maintenance Database" so the table fits on the page; if you want that unbroken, you should again use a \multicolumn

3

If you don't mind changing the style of your table a little bit, I'd advise using booktabs, it makes the table look much cleaner and nice. If you still want your own table fixed, let me know in a comment.

The command L{3cm}in the table header means that a certain column will have left-alignment and will have a width of 3cm. You're free to change that. Since the first column was a little number, I just wrote l which just gives the alignment, no width.

table image

\documentclass{article} \usepackage[a4paper]{geometry} \usepackage[utf8]{inputenc} \usepackage{booktabs} \usepackage{tabulary} \newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}} \begin{document} \begin{table} \begin{tabular}{l*{4}{L{3cm}}} \toprule & Name & Function & Properties & Relationships \\ \midrule 7 & System Maintenance Database & Stores all kinds of errors occurred during operation from all components in a specified way & Only error related information is stored & \\ 9 & Main Database & & \\ \bottomrule \end{tabular} \caption{Data elements} \label{data} \end{table} \end{document} 
3
  • With booktabs look better, no doubt, but the real improvement in style was remove the vertical lines and double lines. :) Commented Oct 26, 2013 at 18:39
  • @Fran Indeed, but I think that in the documentation of the package itself it is advised to avoid vertical lines altogether. If I remember well. The advantage of booktabs is also that it provides some auto-spacing for the midrules. :D Commented Oct 26, 2013 at 19:12
  • Of course. It is a shame that does not work well with colored rows because this, but in other case tables are indeed more elegant with booktabs. Commented Oct 26, 2013 at 20:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.