LaTeX forum ⇒ Graphics, Figures & Tablestrivfloat and caption position

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

trivfloat and caption position

Postby drpencilcase » Thu Apr 22, 2010 6:09 am

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

  1. \documentclass{article}
  2. \usepackage{booktabs}
  3. \usepackage{trivfloat}
  4.  
  5. \trivfloat{boxx}
  6.  
  7. \begin{document}
  8. \begin{table}[htb]
  9. \caption{Table title}
  10. \centering
  11. \begin{tabular}{ l c c }
  12. \toprule[2pt]
  13. A1 & A2 & A3 \\
  14. \midrule
  15. A1 & A2 & A3 \\
  16. A1 & A2 & A3 \\
  17. A1 & A2 & A3 \\
  18. A1 & A2 & A3 \\
  19. \bottomrule[2pt]
  20. \end{tabular} \label{tab:table1}
  21.  
  22. \end{table}
  23.  
  24.  
  25.  
  26. \begin{boxx}[htb]
  27. \caption{Box Title}
  28. \centering
  29. \begin{tabular}{ l c c }
  30. \toprule[2pt]
  31. A1 & A2 & A3 \\
  32. \midrule
  33. A1 & A2 & A3 \\
  34. A1 & A2 & A3 \\
  35. A1 & A2 & A3 \\
  36. A1 & A2 & A3 \\
  37. \bottomrule[2pt]
  38. \end{tabular}
  39. \label{tab:box1}
  40.  
  41. \end{boxx}
  42.  
  43.  
  44. \end{document}

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

Postby gmedina » Thu Apr 22, 2010 6:23 am

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:

  1. \documentclass{article}
  2. \usepackage{booktabs}
  3. \usepackage{caption}
  4.  
  5. \DeclareCaptionType{boxx}
  6.  
  7. \begin{document}
  8.  
  9. \begin{table}[htb]
  10. \caption{Table title}
  11. \centering
  12. \begin{tabular}{ l c c }
  13. \toprule[2pt]
  14. A1 & A2 & A3 \\
  15. \midrule
  16. A1 & A2 & A3 \\
  17. A1 & A2 & A3 \\
  18. A1 & A2 & A3 \\
  19. A1 & A2 & A3 \\
  20. \bottomrule[2pt]
  21. \end{tabular} \label{tab:table1}
  22. \end{table}
  23.  
  24. \begin{boxx}[htb]
  25. \caption{Box Title}
  26. \centering
  27. \begin{tabular}{ l c c }
  28. \toprule[2pt]
  29. A1 & A2 & A3 \\
  30. \midrule
  31. A1 & A2 & A3 \\
  32. A1 & A2 & A3 \\
  33. A1 & A2 & A3 \\
  34. A1 & A2 & A3 \\
  35. \bottomrule[2pt]
  36. \end{tabular}
  37. \label{tab:box1}
  38. \end{boxx}
  39.  
  40. \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

Postby josephwright » Thu Apr 22, 2010 8:00 am

The trivfloat package is a "simple" interface to the underlying float package. You need to use float's mechanism here:
  1. \documentclass{article}
  2. \usepackage{booktabs}
  3. \usepackage{trivfloat}
  4.  
  5. \trivfloat{boxx}
  6. \floatstyle{plaintop}
  7. \restylefloat{boxx}
  8.  
  9. \begin{document}
  10.  
  11. \begin{table}[htb]
  12. \caption{Table title}
  13. \centering
  14. \begin{tabular}{ l c c }
  15. \toprule[2pt]
  16. A1 & A2 & A3 \\
  17. \midrule
  18. A1 & A2 & A3 \\
  19. A1 & A2 & A3 \\
  20. A1 & A2 & A3 \\
  21. A1 & A2 & A3 \\
  22. \bottomrule[2pt]
  23. \end{tabular} \label{tab:table1}
  24.  
  25. \end{table}
  26.  
  27.  
  28.  
  29. \begin{boxx}[htb]
  30. \caption{Box Title}
  31. \centering
  32. \begin{tabular}{ l c c }
  33. \toprule[2pt]
  34. A1 & A2 & A3 \\
  35. \midrule
  36. A1 & A2 & A3 \\
  37. A1 & A2 & A3 \\
  38. A1 & A2 & A3 \\
  39. A1 & A2 & A3 \\
  40. \bottomrule[2pt]
  41. \end{tabular}
  42. \label{tab:box1}
  43.  
  44. \end{boxx}
  45.  
  46.  
  47. \end{document}
Joseph Wright

drpencilcase
Posts: 2
Joined: Thu Apr 22, 2010 5:58 am

Postby drpencilcase » Thu Apr 22, 2010 2:29 pm

Thanks for the quick reply. Both solutions were satifactory.

Felipe


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 2 guests