Graphics, Figures & Tablesone table with two columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
rudrales
Posts: 16
Joined: Wed Mar 11, 2009 1:52 am

one table with two columns

Post by rudrales »

I've one table but the table uses only the half of the the page width. I think it's waste of space.

Does somebody know a command that the table can be split up into two columns? Or do I have to write the table with two columns from the begin?

I used these code for the table:

Code: Select all

\begin{table}
  \begin{tabular}{|l|l|l|}
    Names & Values & Type \\
    Names & Values & Type \\
  \end{tabular}
\end{table}
At the end, it should look like this:
|Names | Values | Type | |Names | Values | Type |


Thank you for your trouble

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

one table with two columns

Post by localghost »

Manual splitting is the only idea I have at the moment. You could typeset two tables side by side.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs}
\usepackage{lmodern}

\parindent0em

\begin{document}
  \begin{table}[!ht]
    \centering
    \caption{A table split into two columns}\label{tab:split}
    \begin{tabular}{lll}\toprule
      Names & Values & Type \\ \midrule
      rudrales & 1 & \LaTeX\ newbie \\ \bottomrule
    \end{tabular}
    \hspace{1cm}
    \begin{tabular}{lll}\toprule
      Names & Values & Type \\ \midrule
      rudrales & 1 & \LaTeX\ newbie \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}
An alternative could be to make the surrounding text wrap the table by using the wrapfig package.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs}
\usepackage{lmodern}
\usepackage{wrapfig}
\usepackage{blindtext}

\parindent0em

\begin{document}
  \begin{wraptable}{l}{7cm}
    \centering
    \caption{A wrapped table}\label{tab:wrap}
    \begin{tabular}{lll}\toprule
      Names & Values & Type \\ \midrule
      rudrales & 1 & \LaTeX\ newbie \\ \bottomrule
    \end{tabular}
  \end{wraptable}
  \blindtext
\end{document}

Best regards
Thorsten¹
rudrales
Posts: 16
Joined: Wed Mar 11, 2009 1:52 am

Re: one table with two columns

Post by rudrales »

Thank you Thorsten for the answer

The first given advice looks how I want it but I've to split the table. I don't like it because I'm increasing the table constant. If I don't find an other solution I'll write the code how you gave me advice.

The second proposal doesn't work. I've the following error: LaTeX Error: File 'blindtext.sty' not found. How can I fix the error?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

one table with two columns

Post by localghost »

rudrales wrote:[...]The second proposal doesn't work. I've the following error: LaTeX Error: File 'blindtext.sty' not found. How can I fix the error?
The blindtext package is for producing longer text passages and other demonstration purposes. You don't really need it. But you can install it with the package of your LaTeX distribution.
rudrales
Posts: 16
Joined: Wed Mar 11, 2009 1:52 am

Re: one table with two columns

Post by rudrales »

I'm a beginner. I don't know how to install single package. I installed only the gwTeX. I don't know what that's but the LaTeX works in principle.

I deleted the blindtext package from the code and I could "compile" the source code but the tables are stacked. Do I overlook something?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

one table with two columns

Post by localghost »

rudrales wrote:I'm a beginner. I don't know how to install single package. I installed only the gwTeX. I don't know what that's but the LaTeX works in principle. [...]
I don't have any experience with TeX on a Mac. It seems that your distribution is outdated [1]. Packages should be kept up-to-date. So I suggest to take a look at MacTeX.
rudrales wrote:[...] I deleted the blindtext package from the code and I could "compile" the source code but the tables are stacked. Do I overlook something?
It goes without saying that you have to replace the \blindtext command with your own text. Here is the last example without the blindtext package.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs}
\usepackage{lmodern}
\usepackage{wrapfig}

\parindent0em

\begin{document}
  \begin{wraptable}{l}{7cm}
    \centering
    \caption{A wrapped table}\label{tab:wrap}
    \begin{tabular}{lll}\toprule
      Names & Values & Type \\ \midrule
      rudrales & 1 & \LaTeX\ newbie \\ \bottomrule
    \end{tabular}
  \end{wraptable}
  The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
\end{document}
[1] i-Installer Home page
rudrales
Posts: 16
Joined: Wed Mar 11, 2009 1:52 am

Re: one table with two columns

Post by rudrales »

Thank you, Thorsten. Everything is working fine. I'm going to try the TeXMac. I knew the i-Installer is outdated but I thought also an older version is good enough for my begin with LaTeX.
Post Reply