2

The code

\documentclass{report}
\begin{document}
    \begin{tabular}{|l|l|}
        \hline{}
        A & B\\
        \hline{}
        C & D\\
        \hline{}
    \end{tabular}
\end{document}

Looks like this:
enter image description here

I don't want any more vertical lines under C and D.

And if I take away the first line, so that my code looks like this:

\documentclass{report}
\begin{document}
    \begin{tabular}{|l|l|}
        A & B\\
        \hline{}
        C & D\\
        \hline{}
    \end{tabular}
\end{document}

A gets moved to the left like so:
enter image description here

How do I fix these issues?

  • 1
    For the first question, who told you a atbular must end with a \\? It creates a new row. – Bernard Jan 23 '19 at 15:57
  • It does not compile without the `\\`... – Tvde1 Jan 23 '19 at 16:04
  • I see. You want to type \hline, so you need it, but adding {} does create a new row. – Bernard Jan 23 '19 at 16:11
2

Simply use \hline instead of \hline{} ...

See the following code

\documentclass{report}

\begin{document}
\begin{tabular}{|l|l|}
  \hline
  A & B\\
  \hline
  C & D\\
 \hline
\end{tabular}
\end{document}

and the result:

enter image description here

Have you considered to not use vertical lines? Makes better looking tables ...

| improve this answer | |

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.