Graphics, Figures & TablesExcel-like tables of experimental data

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Excel-like tables of experimental data

Post by Cham »

Sorry if I sounded under stress. I was actually excited, since I solved most of my problems ! 8-)

Now, I believe that the align environment is very natural, to align the tables to their left.

So the only thing missing is that double line which is too long. Instead of using the \hhline, I would prefer to keep the small gap. I think it looks nice. However, how to adapt the line to the upper block ?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Excel-like tables of experimental data

Post by Johannes_B »

Align is a math environment to align, for example, equal signs vertically in different lines.

Did you try my proposal?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Excel-like tables of experimental data

Post by Cham »

Not yet. And I'm not familiar with minipage.

Can you offer an example, just to align two tables ?

And what about the double lines (with a gap) without using hhline ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Excel-like tables of experimental data

Post by Johannes_B »

Why do you want to avoid package hhline? It was developed just for that purpose of doing what you want to do.

You don't need anything to have the tables aligned, minipages just to make the upper and lower stuck together. You can center the minipage.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Excel-like tables of experimental data

Post by Cham »

Sorry, I don't understand about the minipage. Can you be more specific ?

An example would help.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Excel-like tables of experimental data

Post by Johannes_B »

Code: Select all

\documentclass[10pt,twoside]{revtex4}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{microtype}
\usepackage{hhline}
\usepackage{showframe}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage[separate-uncertainty=true]{siunitx}
\sisetup{output-decimal-marker = {,}}

\begin{document}

\section*{A table of results}

\begin{center}
\noindent
\begin{minipage}{.8\linewidth}
	\renewcommand{\arraystretch}{1.5}
	\begin{tabular}{l|c|c|c|c|c|}
		\cline{2-6}
		& \multicolumn{5}{c|}{Tableau 2.  Caractéristiques physiques d'un petit cylindre de métal}                                             \\ \cline{2-6}
		& \multicolumn{1}{>{\centering}p{6em}|}{$d$}
		& \multicolumn{1}{>{\centering}p{6em}|}{$\Delta d$}
		& \multicolumn{1}{>{\centering}p{6em}|}{$\ell$}
		& \multicolumn{1}{>{\centering}p{6em}|}{$\Delta\ell$}
		& \multicolumn{1}{>{\centering}p{6em}|}{$m$}
		\\ \cline{2-6}
		& \multicolumn{2}{c|}{\si{\mm}}
		& \multicolumn{2}{c|}{\si{\mm}}
		& \si{\g}
		\\ \cline{2-6}
		& \multicolumn{2}{c|}{–}
		& \multicolumn{2}{c|}{–}
		& 0,1 \\
%		\hline\hline
		\hhline{b-=====}
%		\hline
		\multicolumn{1}{|l|}{Règle} & 15 & 1 & 22 & 1 & \multirow{3}{*}{49,3} \\ \cline{1-5}
		\multicolumn{1}{|l|}{Pied à coulisse} & 15,4 & 0,1 & 22,6 & 0,1 & \\ \cline{1-5}
		\multicolumn{1}{|l|}{Palmer} & 15,42 & 0,03 & 22,57 & 0,02 & \\ \hline
	\end{tabular} \\[10pt]

	\begin{tabular}{|l|}
		\hline
		\multicolumn{1}{|c|}{Légende} \\ \hline
		$d$ est le diamètre du cylindre. \\
		$\ell$ est la longueur du cylindre. \\
		$m$ est la masse du cylindre, selon la balance à fléaux. \\ \hline
	\end{tabular}
\end{minipage}
\end{center}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Excel-like tables of experimental data

Post by Cham »

Thanks a lot, Johannes, it's really appreciated !

I'll study this later today.

EDIT : Just a simple question : the align environment works too, even if it was designed for maths. Why the mini page is a better way to align the tables ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Excel-like tables of experimental data

Post by Johannes_B »

Maths is for maths.

I know your documents are math-heavy. If you have a long set of aligned equations, you might want to allow this set to break pages. This will affext all sets of equations, even the two tabular environments. Hence, they might split to different pages, which makes a legend (non-sticky) kind of useless.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Excel-like tables of experimental data

Post by Cham »

So does that mean that the minipage will not break the legend from its main table ?

Also, if I want to display several tables (say two relatively small tables), is it a good idea to define both of them inside the same mini page, so their legends are all aligned together to the left ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Excel-like tables of experimental data

Post by Johannes_B »

If the table and the legend are within a minpage, they won't split. As far as LaTeX is concerned, the minipage is like one letter, like a bix X or a big y.

If you want to keep both tables together, put them in one minipage. If you want the tables and legends to stick together, but let the tables (tabular and legend) split, but the constructs in different minipages.

Since a table (data, information, a box for latex) can be quite large, they are usually put in a floating environment (called table, yes; this is confusing) to ensure the usual nice flow of text.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply