Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

These limitations and difficulties I face because I couldn't use caption package. If I add \usepackage{caption}, I couldn't preview my document.. I'm using BaKoMa TeX. There are a lot of bugs which is beyond repair for this moment. :-(

  1. I need to have the word Figure in the figure environment caption to be bold. (same goes for table)

  2. If possible I want the caption length is equal to table's width and it is in single spacing. The whole document is in double spacing. For example

enter image description here

Here is the LaTeX code:

\documentclass{report}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs,xcolor,amssymb} %% also needed
\begin{document}
\begin{table}[H]\label{comparisonfourierandnonfourier1}\caption{Comparison between Fourier and Non-Fourier heat conduction equation (HCE).}\centering
\begin{tabular}{l c c}
\toprule
\textbf{\textcolor{blue}{Item}} & \textbf{\textcolor{blue}{Fourier HCE}} &    
\textbf{\textcolor{blue}{non-Fourier HCE}}\\
\midrule
1) conservation energy & same & same \\ 
2) heat flux equation & $q=-k\triangledown T$ & $\tau\displaystyle\frac{\partial q}   
{\partial t}+q=-k\frac{\partial T}{\partial r}$ \\ 
3) equation form & parabolic  & hyperbolic \\ 
4) heat propagation & infinite  & finite \\ 
5) temperature gradient & moderate  & extreme \\ 
\bottomrule\end{tabular}
\end{table}
\end{document}

Is there any other way to do this given that the limitation I face... by only using the graphicx package? Maybe some \renewcommand perhaps... I do appreciate for your advice.

share|improve this question
add comment

1 Answer

I've taken your MWE and made the following main changes:

  • I inserted the full definition of the internal LaTeX macro \@makecaption (from report.cls) and changed its settings so that the float's name (Figure or Table) and number are set in bold. (Aside: This partial redefinition of the macro \@makecaption could be accomplished more elegantly, in general, by loading the etoolbox package and invoking the \patchcmd macro. However, since your TeX distribution appears to be so old that the caption package won't even work correctly, I have a hunch that the etoolbox package won't be available either...)
  • I changed the table environment from tabular to tabular* and provided further code so that the table automatically occupies a width of \textwidth (by adding the unwieldy-looking item @{\extracolsep{\fill}}).
  • You mention separately that your document is set double-spaced but that you want the caption's text (if it occupies more than 1 line) to be single-spaced. Your MWE doesn't actually show how you achieve double-spacing, so I've tried to mimic that by loading the setspace package and invoking \doublespacing. This approach has an important advantage: all items such as footnotes and floats will automatically be single-spaced regardless of the spacing in the "main" body of the document.

An additional comment: Always place the \label command after the float's \caption command. Otherwise, your cross-references won't be correct.

enter image description here

\documentclass{report}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs,xcolor,amssymb} %% also needed
\usepackage{setspace}
\doublespacing
\makeatletter
% need to modify definition of \@makecaption macro
% (found in report.cls)
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{\textbf{#1}: #2}% % change "#1" to "\textbf{#1}"
  \ifdim \wd\@tempboxa >\hsize
    \textbf{#1}: #2\par             % change "#1" to "\textbf{#1}"
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\makeatother
\begin{document}
\begin{table}
\caption{Comparison between Fourier and Non-Fourier heat conduction equation (HCE).}
\label{comparisonfourierandnonfourier1}
%\centering % no longer needed
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}} c c@{}}
\toprule
\textbf{\textcolor{blue}{Item}} & \textbf{\textcolor{blue}{Fourier HCE}} &    
\textbf{\textcolor{blue}{non-Fourier HCE}}\\
\midrule
1) conservation energy & same & same \\ 
2) heat flux equation & $q=-k\triangledown T$ & 
   $\tau\displaystyle\frac{\partial q}   
   {\partial t}+q=-k\frac{\partial T}{\partial r}$ \\[1.5ex]
3) equation form & parabolic  & hyperbolic \\ 
4) heat propagation & infinite  & finite \\ 
5) temperature gradient & moderate  & extreme \\ 
\bottomrule
\end{tabular*}
\end{table}
\end{document}
share|improve this answer
    
thank you mico, it works good after adding your modification to my preamble. but i do only want the caption to be in single line and not the table content... which part should i check to make the table's content to be double spacing back? thank you for your advise. –  azlanaznam Jul 27 '12 at 2:11
    
@azlanaznam - Thanks for letting me know that the suggestions work for you. If you want to maintain your previous method for achieving double-spaced text (which you haven't given us any details about so far), you are obviously free to do so. :-) Just don't load the setspace package in that case. –  Mico Jul 27 '12 at 2:31
    
after I uncomment 'setspace' package, the document returns back to double spacing, unfortunately the caption aren't as equal as the table's width. my apology for not mentioning how I set my document as double spacing. here is the command '\renewcommand{\baselinestretch}{2}' –  azlanaznam Jul 27 '12 at 3:31
    
@azlanaznam: When you say that "the caption[s] aren't as [wide] as the table" -- just how wide are they? Are they wider (e.g., as wide as the text block), or are they less wide? Relatedly, did you make the switch from tabular to tabular* environments? (The tabular* environments allows you to specify a set width.) –  Mico Jul 27 '12 at 10:53
1  
@azlanaznam - the double-spacing of the captions is a direct consequence of your choice to set \baselinestretch to 2. (I continue to think that's a terrible setting. Get rid of it, load the setspace package instead, and execute \doublespace.) Please consider posting a new question to explain your remaining issues. –  Mico Jul 28 '12 at 1:27
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.