2

As you have seen in my last questions recently asked here, I'm working with tables.

Usually with tabularx is enough for me to satisfy the needs that I have with my tables. But one of them, even when I put it in two columns, that is, as the table only has 2 columns, I duplicated the to occupy better the width of the page, it still doesn't fit on one page.

I saw that there is a package that combines longtable with tabularx called ltablex and could then solve my problem. I checked the manual (sic) in the CTAN and tried to understand how it works. Since I have no information on the footer, I omitted the creation of it and I tried to create the header following the logic of the package but I can't make the table display complete in the page.

My MWE:

\documentclass[fontsize=12pt,paper=letter,headings=small,bibliography=totoc,DIV=9,headsepline=true,titlepage=on]{scrartcl} 
\usepackage[spanish,mexico]{babel} 
\usepackage{fontspec} 
\defaultfontfeatures{Ligatures=TeX,Mapping=tex-text}
\usepackage{xunicode}
\setmainfont[
 ItalicFont = SourceSerifPro,
 ItalicFeatures={FakeSlant=0.2}
 ]{SourceSerifPro} 
\setsansfont{SourceSansPro} 
\setmonofont{SourceCodePro}
\usepackage{xspace} 
\usepackage{xkeyval}
\usepackage{array,multirow,multicol,rotating,tabularx,ragged2e,booktabs,ltablex} 
\newcolumntype{Z}{>{\RaggedLeft\arraybackslash\hspace{0pt}}X}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}    
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{bc}
\setcellgapes{1.5pt}

\begin{document}

\begin{table}[htb]
\caption{Empresas Interesadas en la Explotación de los hidrocarburos de México}
\label{tab:interesadas}
\centering
\begin{tabularx}{\linewidth}{@{}Y l Y l @{}}
\toprule
Nombre & País de Origen & Nombre & País de Origen \\
\midrule
\endfirsthead

\toprule
Nombre & País de Origen & Nombre & País de Origen \\
\midrule
\endhead

%Nothing in footer

Atlantic Rim México, S. DE R.L. DE C.V. & Estados Unidos & Marathon Offshore Investment Limited & Estados Unidos \\
BG Group Mexico Exploration, S.A. de C.V. & Inglaterra & Mitsubishi Corporation & Japón \\ 
BHP Billiton Petróleo Operaciones de México, S. de R.L. de C.V. & Australia-Inglaterra & Murphy Worldwide, Inc. & Estados Unidos \\
BP Exploration México, S.A. de C.V. & Gran Bretaña & NBL Mexico Inc. & Estados Unidos \\
Casa Exploration, L.P. & Estados Unidos & Nexen Energy Holdings International Limited & China \\
Chevron Energía de México, S. de R.L. de C.V. & Estados Unidos & ONGC Videsh Limited & India \\
Cobalt Energía de México, S. de R.L. de C.V. & Estados Unidos & Pan American energy LLC. & Argentina \\
Compañía Española de Petróleo, S.A. (CEPSA) & España & Pacific Rubiales E\&P México S.A.P.I. DE C.V. & Colombia \\
Diavaz Offshore, S.A.P.I. de C.V. & México & Petrobal S.A.P.I. de C.V. & México \\
E\&P Hidrocarburos Y Servicios, S.A. de C.V. & Argentina & Petróleo Brasileiro México, S. de R.L. de C.V. & Brasil \\
Ecopetrol, S.A. & Colombia & Petronas Carigali International E\&P B.V. & Malasia \\
Eni International B.V. & Italia & Plains Acquisition Corporation & Estados Unidos \\
Exxon Mobil, S.A. & Estados Unidos & Pluspetrol México B.V. & Argentina \\
Galp Energia E\&P B.V. & Portugal & Premier Oil PLC & Inglaterra \\
Glencore E\&P Mexico LTD. & Suiza & PTT Exploration and Production Public Company Limited & Tailandia \\
Hess New Ventures Limited & Estados Unidos & Shell Exploración y Extracción de México, S.A. de C.V. & Inglaterra-Holanda \\
Hunt Overseas Oil Company & Estados Unidos & Sierra Oil \& Gas, S. de R.L. de C.V. & México \\
Inpex Corporation & Japón & Statoil E\&P México, S.A. de C.V. & Noruega \\
Japan Oil, Gas and Metals National Corporation & Japón & Talos Energy LLC & Estados Unidos \\
Japan Petroleum Exploration Co., Ltd. & Japón & Total, S.A. & Francia \\
Lukoil Overseas Netherlands B.V. & Rusia & Tullow México B.V. & Inglaterra \\
M{\ae}rsk Olie OG GAS A/S & Dinamarca & Woodside Energy Mediterranean Pty LTD & Australia \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

I don't know what's wrong with this. Should I include a footer? Should I include \keepXColumns or \convertXColumns? What are they for? How do they work?

  • 3
    At first you shouldn't use the table environment. – Ulrike Fischer Aug 5 '15 at 21:52
2

The third page of the table (to show referencing):

enter image description here

\documentclass[fontsize=12pt,paper=letter,headings=small,bibliography=totoc,DIV=9,headsepline=true,titlepage=on]{scrartcl} 
\usepackage[spanish,mexico]{babel} 
\usepackage{fontspec} 
\defaultfontfeatures{Ligatures=TeX,Mapping=tex-text}
\usepackage{xunicode}
\setmainfont[
 ItalicFont = SourceSerifPro,
 ItalicFeatures={FakeSlant=0.2}
 ]{SourceSerifPro} 
\setsansfont{SourceSansPro} 
\setmonofont{SourceCodePro}
\usepackage{xspace} 
\usepackage{xkeyval}
\usepackage{array,multirow,multicol,rotating,tabularx,ragged2e,booktabs,ltablex} 
\newcolumntype{Z}{>{\RaggedLeft\arraybackslash\hspace{0pt}}X}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}    
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{bc}
\setcellgapes{1.5pt}

\begin{document}

{%
\captionof{table}{Empresas Interesadas en la Explotación de los hidrocarburos de México}
\label{tab:interesadas}
\begin{tabularx}{\linewidth}{@{}Y l Y l @{}}
\toprule
Nombre & País de Origen & Nombre & País de Origen \\
\midrule
\endfirsthead

\toprule
Nombre & País de Origen & Nombre & País de Origen \\
\midrule
\endhead

%Nothing in footer

Atlantic Rim México, S. DE R.L. DE C.V. & Estados Unidos & Marathon Offshore Investment Limited & Estados Unidos \\
BG Group Mexico Exploration, S.A. de C.V. & Inglaterra & Mitsubishi Corporation & Japón \\ 
BHP Billiton Petróleo Operaciones de México, S. de R.L. de C.V. & Australia-Inglaterra & Murphy Worldwide, Inc. & Estados Unidos \\
BP Exploration México, S.A. de C.V. & Gran Bretaña & NBL Mexico Inc. & Estados Unidos \\
Casa Exploration, L.P. & Estados Unidos & Nexen Energy Holdings International Limited & China \\
Chevron Energía de México, S. de R.L. de C.V. & Estados Unidos & ONGC Videsh Limited & India \\
Cobalt Energía de México, S. de R.L. de C.V. & Estados Unidos & Pan American energy LLC. & Argentina \\
Compañía Española de Petróleo, S.A. (CEPSA) & España & Pacific Rubiales E\&P México S.A.P.I. DE C.V. & Colombia \\
Diavaz Offshore, S.A.P.I. de C.V. & México & Petrobal S.A.P.I. de C.V. & México \\
E\&P Hidrocarburos Y Servicios, S.A. de C.V. & Argentina & Petróleo Brasileiro México, S. de R.L. de C.V. & Brasil \\
Ecopetrol, S.A. & Colombia & Petronas Carigali International E\&P B.V. & Malasia \\
Eni International B.V. & Italia & Plains Acquisition Corporation & Estados Unidos \\
Exxon Mobil, S.A. & Estados Unidos & Pluspetrol México B.V. & Argentina \\
Galp Energia E\&P B.V. & Portugal & Premier Oil PLC & Inglaterra \\
Glencore E\&P Mexico LTD. & Suiza & PTT Exploration and Production Public Company Limited & Tailandia \\
Hess New Ventures Limited & Estados Unidos & Shell Exploración y Extracción de México, S.A. de C.V. & Inglaterra-Holanda \\
Hunt Overseas Oil Company & Estados Unidos & Sierra Oil \& Gas, S. de R.L. de C.V. & México \\
Inpex Corporation & Japón & Statoil E\&P México, S.A. de C.V. & Noruega \\
Japan Oil, Gas and Metals National Corporation & Japón & Talos Energy LLC & Estados Unidos \\
Japan Petroleum Exploration Co., Ltd. & Japón & Total, S.A. & Francia \\
Lukoil Overseas Netherlands B.V. & Rusia & Tullow México B.V. & Inglaterra \\
M{\ae}rsk Olie OG GAS A/S & Dinamarca & Woodside Energy Mediterranean Pty LTD & Australia \\
\bottomrule
\end{tabularx}
}%
Table \ref{tab:interesadas} shows ...
\end{document}

First, as suggested by @UlrikeFischer, you should get rid of the table environment because, as the documentation says:

The file modifies the tabularx environment to combine the features of the tabularx package (auto-sized columns in a fixed width table) with those of the longtable package (multi-page tables).

So, you needn't add table. For referencing just use the \captionof command with adding your label. It is better to add two braces {} around the table to prevent \captionof errors.

  • Great! it works. Now a silly question: There is a very long time I see code samples where at the end of a line people add a % symbol, no matters if there is a comment following that symbol or not. Now in your answer, you and a pair of % also after the braces you suggest me include (that worked BTW). So my question is why people do that? It has an special meaning or a reason for that? – Aradnix Aug 6 '15 at 1:01

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.