Graphics, Figures & Tablestrivfloat and caption position

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
drpencilcase
Posts: 2
Joined: Thu Apr 22, 2010 5:58 am

trivfloat and caption position

Post by drpencilcase »

I'm having problem setting caption position using trivfloat. I just recently started using latex but from what I understood the caption position should be based if i put the \caption command before or after the actual tabulation. It works as I expected when I use table but I need a second type of tables (which I called boxx on the example) and caption is placed after the table...I need it before.

Am I doing anything wrong? If not, is there a workaround?

Thanks,

Felipe Barbosa

Code: Select all

\documentclass{article}
\usepackage{booktabs} 
\usepackage{trivfloat}

\trivfloat{boxx}

\begin{document}
\begin{table}[htb]
	\caption{Table title}
	\centering
	\begin{tabular}{ l c c  }
	\toprule[2pt]
			A1 & A2 & A3 \\
	\midrule
			A1 & A2 & A3 \\
			A1 & A2 & A3 \\
			A1 & A2 & A3 \\
			A1 & A2 & A3 \\		
	\bottomrule[2pt]
	\end{tabular}	\label{tab:table1}
	
\end{table}



\begin{boxx}[htb]
	\caption{Box Title}
	\centering
	\begin{tabular}{ l c c  }
	\toprule[2pt]
			A1 & A2 & A3 \\
	\midrule
			A1 & A2 & A3 \\
			A1 & A2 & A3 \\
			A1 & A2 & A3 \\
			A1 & A2 & A3 \\		
	\bottomrule[2pt]
	\end{tabular}
	\label{tab:box1}
	
\end{boxx}


\end{document}

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

trivfloat and caption position

Post by gmedina »

Hi,

perhaps there's a solution using trivfloat, but I couldn't find it (I don't have much time right now and I only browsed really quickly through the documentation). Instead of trivfloat, you could use the \DeclareCaptionType command provided by the caption package:

Code: Select all

\documentclass{article}
\usepackage{booktabs} 
\usepackage{caption}

\DeclareCaptionType{boxx}

\begin{document}

\begin{table}[htb]
   \caption{Table title}
   \centering
   \begin{tabular}{ l c c  }
   \toprule[2pt]
         A1 & A2 & A3 \\
   \midrule
         A1 & A2 & A3 \\
         A1 & A2 & A3 \\
         A1 & A2 & A3 \\
         A1 & A2 & A3 \\      
   \bottomrule[2pt]
   \end{tabular}   \label{tab:table1}
\end{table}

\begin{boxx}[htb]
   \caption{Box Title}
   \centering
   \begin{tabular}{ l c c  }
   \toprule[2pt]
         A1 & A2 & A3 \\
   \midrule
         A1 & A2 & A3 \\
         A1 & A2 & A3 \\
         A1 & A2 & A3 \\
         A1 & A2 & A3 \\      
   \bottomrule[2pt]
   \end{tabular}
   \label{tab:box1}
\end{boxx}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

trivfloat and caption position

Post by josephwright »

The trivfloat package is a "simple" interface to the underlying float package. You need to use float's mechanism here:

Code: Select all

    \documentclass{article}
    \usepackage{booktabs}
    \usepackage{trivfloat}

    \trivfloat{boxx}
    \floatstyle{plaintop}
    \restylefloat{boxx}

    \begin{document}

    \begin{table}[htb]
       \caption{Table title}
       \centering
       \begin{tabular}{ l c c  }
       \toprule[2pt]
             A1 & A2 & A3 \\
       \midrule
             A1 & A2 & A3 \\
             A1 & A2 & A3 \\
             A1 & A2 & A3 \\
             A1 & A2 & A3 \\      
       \bottomrule[2pt]
       \end{tabular}   \label{tab:table1}
       
    \end{table}



    \begin{boxx}[htb]
       \caption{Box Title}
       \centering
       \begin{tabular}{ l c c  }
       \toprule[2pt]
             A1 & A2 & A3 \\
       \midrule
             A1 & A2 & A3 \\
             A1 & A2 & A3 \\
             A1 & A2 & A3 \\
             A1 & A2 & A3 \\      
       \bottomrule[2pt]
       \end{tabular}
       \label{tab:box1}
       
    \end{boxx}


    \end{document}
Joseph Wright
drpencilcase
Posts: 2
Joined: Thu Apr 22, 2010 5:58 am

Re: trivfloat and caption position

Post by drpencilcase »

Thanks for the quick reply. Both solutions were satifactory.

Felipe
Post Reply