General ⇒ Help on \subtable
-
- Posts: 20
- Joined: Thu Sep 06, 2007 7:31 pm
Help on \subtable
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Help on \subtable
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 20
- Joined: Thu Sep 06, 2007 7:31 pm
Re: Help on \subtable
\usepackage{subfigure}
\begin{document}
\section{Section title}
\begin{table}[h!]
\centering
\subtable[]{
\tiny
\centering
\begin{tabular}{|c|c|c|}\hline
a&b&c\\
d&e&f\\\hline
\end{tabular}
\label{tab:chapter4:1a}
}
\subtable[]{
\tiny
\centering
\begin{tabular}{|c|c|c|}\hline
g&h&i\\
j&k&l\\\hline
\end{tabular}
\label{tab:chapter4:1b}
}
\subtable[]{
\tiny
\centering
\begin{tabular}{|c|c|c|}\hline
m&n&o\\
p&q&r\\\hline
\end{tabular}
\label{tab:chapter4:1c}
}
\caption{Testing}
\label{tab:chapter4:1}
\end{table}
Here the tables are Table \ref{tab:chapter4:1}, \ref{tab:chapter4:1a}, \ref{tab:chapter4:1b} and \ref{tab:chapter4:1c}.
\end{document}
This is the example I have tried.. It is not giving correctly the subtable numbers. It is showing one less than the actual number.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Help on \subtable
- The simple one is to replace the \ref command for the subtables by the \subref command. For total reference you can use a combination of both.
Code: Select all
Here the tables is Table~\ref{tab:chapter4:1} with its subtables \subref{tab:chapter4:1a}, \subref{tab:chapter4:1b} and \subref{tab:chapter4:1c}. The Table~\ref{tab:chapter4:1}\subref{tab:chapter4:1a} is a subtable of Table~\ref{tab:chapter4:1}
- The better one is to change to the subfig package and modify the code. The changes are only marginal, so the code looks like the one you provided.
Code: Select all
\documentclass[12pt,BCOR13mm,DIV15]{scrartcl} % KOMA Script article class \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage[font=small,labelfont=bf]{caption} \usepackage[font=footnotesize]{subfig} \setlength{\parindent}{0pt} \begin{document} \section{Section title} \begin{table}[!ht] \centering \subfloat[First Subtable\label{tab:chapter4:1a}]{ \tiny \centering \begin{tabular}{|c|c|c|}\hline a&b&c\\ d&e&f\\\hline \end{tabular} } \subfloat[Second Subtable\label{tab:chapter4:1b}]{ \tiny \centering \begin{tabular}{|c|c|c|}\hline g&h&i\\ j&k&l\\\hline \end{tabular} } \subfloat[Third Subtable\label{tab:chapter4:1c}]{ \tiny \centering \begin{tabular}{|c|c|c|}\hline m&n&o\\ p&q&r\\\hline \end{tabular} } \caption{Testing}\label{tab:chapter4:1} \end{table} Here the tables are Table~\ref{tab:chapter4:1}, \ref{tab:chapter4:1a}, \ref{tab:chapter4:1b} and \ref{tab:chapter4:1c}. The Table~\ref{tab:chapter4:1}\subref{tab:chapter4:1a} is a subtable of Table~\ref{tab:chapter4:1}. Table~\ref{tab:chapter4:1} has also the two other subtables \ref{tab:chapter4:1}\subref*{tab:chapter4:1b} and \ref{tab:chapter4:1}\subref{tab:chapter4:1c} \end{document}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 20
- Joined: Thu Sep 06, 2007 7:31 pm
Re: Help on \subtable
-
- Posts: 20
- Joined: Thu Sep 06, 2007 7:31 pm
Re: Help on \subtable
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Help on \subtable
chandangiri wrote: It is working fine.. but will it also work for subfigures?
Now let me think … hm … Of course it works with figures! What did you think? I already recommended to take look at the documentation. That's what these papers are made for. (Sorry if I hit the wrong note.)
chandangiri wrote: If the tables are large table (i.e not fit within the page width) then also tables are put side by side. So how the tables can be put one after another automatically in this case. If the Tables are small then again it should be fitted within one row.
I guess you are meaning that only one single table fits the linewidth. You can add a line break command to force the right placement.
Code: Select all
\begin{table}[!ht]
\centering
\subfloat[First Subfloat\label{subtab-1:table}{
…
}\\ %<<<< here is the line break
\subfloat[Second Subfloat\label{subtab-2:table}{
…
}
\caption{Table}\label{tab:table}
\end{table}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10