I would like to know if it is possible to copy a table from Excel with the configurations to Latex.
I use Microsoft Excel 2016 for Max OS X.
Thank you!
exceltables
I would like to know if it is possible to copy a table from Excel with the configurations to Latex.
I use Microsoft Excel 2016 for Max OS X.
Thank you!
The package siunitx
could be a solution for you, but it requires some adjustment of the excel2latex
output, which I'll explain below. siunitx
defines a special column type, S
used in place of the usual l
,c
,r
specifications.
Each cell entry is then taken as the argument to siunitx
's \num{}
command, which accepts scientific notation input as 1.00E-02.
One behavior of this solution is that siunitx
centers the columns around the decimal separator. siunitx
tries to be smart about what is text/headings and what is numerical data. But anything that could be mistaken for numerical data (in your example, the first row, which I'm assuming contains headings) should be protected with curly braces.
So, to apply this solution to excel2latex
output, you'll have to:
siunitx
package in the document preamble,c
(or l
or r
) to s
in the beginning of the tabular
environment for any columns with numerical data, and{}
.An example:
\begin{tabular}{cc}
1 & 2 \\
1.00E-02 & 1.05E-03 \\
\end{tabular}
\begin{tabular}{SS}
{1} & {2} \\
1.00E-02 & 1.05E-03 \\
\end{tabular}
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{SS}
{1} & {2} \\
1.00E-02 & 1.05E-03 \\
\end{tabular}
\end{document}
Many adjustments can be made for alignment and spacing of the S
columns. If you decide this solution is workable for you, you can consult the package manual (Section 4.6) for details.
I'm back and I found a partial solution to my problem.
Please keep in mind that I am almost a complete beginner so I'm experimenting. ^^'
(I'm using Overleaf to write my code because I tried on RStudio but the datatool package was apparently not available for R version 3.5.1)
So to simplify, this is the pattern I used:
% Load CSV database (here database.csv)
% and give it a label (here DB)
\DTLloaddb{DB}{database.csv}
%%%%%%%%%%%%%%%%
% Iteration
% Here in the D column I can have d1, d2, etc.
% but I only want to display the result for the rows with d1:
\DTLforeach*[\DTLiseq{\D}{d1}] % Condition
{DB} % Database label
{\A=A,\B=B,\C=C,\D=D,\E=E} % Assignment
{% Stuff to do at each iteration:
\item[]
\textbf{\A}
\textbf{ \B}
\textit{ \C}
(\E)
}
%%%%%%%%%%%%%%%%
In my particular situation, I am doing a wine list/menu (Carte des Vins) and eventually I want to:
1) sort them by wine (Bordeaux / Burgundy / Port / Rest of the World)
For now I'm using a csv file with only the Bordeaux wines (bordeaux.csv) but ultimately I would like to use a file with all the wines on it (wine.csv)
2) sort them by type (Red / White / Sweet white)
As you will see below, I managed to do that, but maybe there is a better way to do the same thing.
3) format the text as follows:
Vintage Name, Classification (Origin)
ex: 2009 Château Grand Village, Bordeaux Supérieur (Bordeaux)
The only thing that I have trouble with is the comma, because when the Classification column is empty I don't want to get "Vintage Name," with a useless comma... So for now I left the text without a comma.
So this is my whole code:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
% Pour modifer les marges
\usepackage{geometry}
% Marges du document
\geometry{hmargin=2.5cm,vmargin=1.5cm}
% To remove the heading of the table of contents ("Contents")
\makeatletter
\renewcommand\tableofcontents{%
\@starttoc{toc}%
}
\makeatother
% To make itemized lists
% This package provides user control over the layout of the three basic list
% environments: enumerate, itemize and description. It supersedes both enumerate
% and mdwlist (providing well-structured replacements for all their funtionality),
% and in addition provides functions to compute the layout of labels, and to
% ‘clone’ the standard environments, to create new environments with counters of
% their own.
\usepackage{enumitem}
% Datatool package to load external files (cdv)
\usepackage{datatool}
\Huge\title{Carte des Vins}
\author{Buck's}
\date{September 2018}
\begin{document}
\maketitle
\tableofcontents
%--------------------------%
\newpage
\section{Bordeaux}
% Load CSV database and give it a name
\DTLloaddb{BOR}{bordeaux.csv}
\subsection{Red}
%%%%%%%%%%%%%%%%
% Iteration
\DTLforeach*[\DTLiseq{\Type}{Red}] % Condition
{BOR} % Database label
{\Vintage=Vintage,\Name=Name,\Classification=Classification,\Type=Type,\Origin=Origin} % Assignment
{% Stuff to do at each iteration:
\item[]
\textbf{\Vintage}
\textbf{ \Name}
\textit{ \Classification}
(\Origin)
}
%%%%%%%%%%%%%%%%
\subsection{White}
%%%%%%%%%%%%%%%%
% Iteration
\DTLforeach*[\DTLiseq{\Type}{White}] % Condition
{BOR} % Database label
{\Vintage=Vintage,\Name=Name,\Classification=Classification,\Type=Type,\Origin=Origin} % Assignment
{% Stuff to do at each iteration:
\item[]
\textbf{\Vintage}
\textbf{ \Name}
\textit{ \Classification}
(\Origin)
}
%%%%%%%%%%%%%%%%
\subsection{Sweet White}
%%%%%%%%%%%%%%%%
% Iteration
\DTLforeach*[\DTLiseq{\Type}{Sweet white}] % Condition
{BOR} % Database label
{\Vintage=Vintage,\Name=Name,\Classification=Classification,\Type=Type,\Origin=Origin} % Assignment
{% Stuff to do at each iteration:
\item[]
\textbf{\Vintage}
\textbf{ \Name}
\textit{ \Classification}
(\Origin)
}
%%%%%%%%%%%%%%%%
%--------------------------%
\newpage
\section{Burgundy}
\subsection{Red}
\subsection{White}
%--------------------------%
\newpage
\section{Rest of the World}
%--------------------------%
\newpage
\section{Port}
%--------------------------------
\end{document}
And this is what I managed to get so far (this is the beginning of my section "Bordeaux" and of my subsection "Red"):
Best Answer
I think you are looking for a macro something like this Excel to Latex
But, please also see the following known issues ...
However, I am using the same, without any problem (but with an older version). Just copy the latex table and don't use "Copy to clipboard".
Just use this .xla file in your excel sheet, go to format option in excel and chose to convert table to latex.