
でテストsiunitx
表を作成する際、カンマの後の数値に一定の精度を持たせ、これらの数値を表の先頭に揃えるために、クールなパッケージを使用します。ドット中央の列にありますが、残念ながら、テキストの位置合わせが行われているためVal 2
、$\beta$
変更されていません。以前のテキストが 2.00 のような場合でも、数値2
は siunitx の値として考慮されますか? または、最初の行 (Val 1 ... Val 3) に別のテーブルを作成する必要がありますか? 納得できません...
これが私のコードです:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{frcursive}
\usepackage{amsmath}
% le package qui pemet de définir des unités et leur affichage
\usepackage{siunitx} % Required : alignement des valeurs etc.
\sisetup{
round-mode = places, % Rounds numbers
round-precision = 2, % to 2 places
}
\begin{document}
%exemples de tableau
\noindent\begin{cursive}Des tableaux:\end{cursive}
\begin{table}[h!]
\begin{center}
\label{tab:table1}
\begin{tabular}{l|c|r} % Alignements: left, center, right
\textbf{Val 1} & \textbf{Val 2} & \textbf{Val 3}\\
$\alpha$ & $\beta$ & $\gamma$ \\
\hline
1 & 1110.1 & a\\
2 & 10.1 & b\\
3 & 23.113231 & c\\
\end{tabular}
\caption{Valeurs basiques}
\vspace{1cm}
\label{tab:table2}
\begin{tabular}{l|S|r} % c devient S ==> unitsx
\textbf{Val 1} & \textbf{Val 2} & \textbf{Val 3}\\
$\alpha$ & $\beta$ & $\gamma$ \\
\hline
1 & 1110.1 & a\\
2 & 10.1 & b\\
3 & 23.113231 & c\\
\end{tabular}
\caption{Valeurs alignées et arrondies}
\end{center}
\end{table}
\end{document}
答え1
table-format
テーブルに表示する小数点以下の桁数を定義する必要があります。table-format=4.2
- 列ヘッダーは数字ではなく、テキストの中央に配置する必要があるため、中括弧で囲む必要があります。
- 表のラベルはキャプションの後に置く必要があります
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{frcursive}
\usepackage{amsmath}
% le package qui pemet de définir des unités et leur affichage
\usepackage{siunitx} % Required : alignement des valeurs etc.
\sisetup{ % this is now globally set, you ma consider to move it inside table
round-mode = places, % Rounds numbers
round-precision = 2, % to 2 places
}
\begin{document}
%exemples de tableau
\noindent\begin{cursive}Des tableaux:\end{cursive}
\begin{table}[h!]
\centering
\begin{tabular}{l|c|r} % Alignements: left, center, right
\textbf{Val 1} & \textbf{Val 2} & \textbf{Val 3}\\
$\alpha$ & $\beta$ & $\gamma$ \\
\hline
1 & 1110.1 & a\\
2 & 10.1 & b\\
3 & 23.113231 & c\\
\hline
\end{tabular}
\caption{Valeurs basiques}
\label{tab:table1}
\vspace{2\baselineskip}
\begin{tabular}{l|S[table-format=4.2]|r} % <---
\textbf{Val 1} & {\textbf{Val 2}} & \textbf{Val 3} \\ % <---
$\alpha$} & {$\beta$} & $\gamma$ \\ % <---
\hline
1 & 1110.1 & a\\
2 & 10.1 & b\\
3 & 23.113231 & c\\
\hline
\end{tabular}
\caption{Valeurs alignées et arrondies}
\label{tab:table2}
\end{table}
\end{document}