LaTeX forum ⇒ Graphics, Figures & TablesChange of justification to \justified in figure captions Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
vichome
Posts: 3
Joined: Wed Dec 19, 2012 11:24 pm

Change of justification to \justified in figure captions

Postby vichome » Fri Dec 21, 2012 4:54 pm

Hi,

How can I change the justification from centered to justified in figure captions?

Document class I use: revtex4-1
Tex Live for Mac

Revtex4-1 does not support the caption package I am using, and the \usepackage command is of no use: justification does change from the original \centered to \raggedright, but not to justified:

  1. \usepackage[labelfont=bf,labelsep=quad,justification=justified]{caption}


The \Declare command does not help either:
  1. \DeclareCaptionJustification{justified}{\justified}


Can the problem be solved by \renew commands? If it can and if someone can help, I need a sufficiently detailed description

Many thanks in advance and happy Christmas!
Victor
Last edited by cgnieder on Fri Dec 21, 2012 4:58 pm, edited 1 time in total.
Reason: added code markup

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Fri Dec 21, 2012 5:35 pm

Hi Victor,

Welcome to the LaTeX community!

As you've already found out caption is not aware of the »revtex4-1« class. I don't think it's easy for a user to change that. I wouldn't use it at all but instead change the internal macro that is responsible for the typesetting of the caption:

  1. \documentclass{revtex4-1}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage[T1]{fontenc}
  4.  
  5. \usepackage{lipsum}% for dummy text
  6.  
  7. \makeatletter
  8. \renewcommand\@make@capt@title[2]{%
  9. \@ifx@empty\float@link{\@firstofone}{\expandafter\href\expandafter{\float@link}}%
  10. {\textbf{#1}}\@caption@fignum@sep#2\quad
  11. }%
  12. \makeatother
  13.  
  14. \begin{document}
  15.  
  16. \lipsum[1]
  17.  
  18. \begin{figure}[ht]
  19. \rule{5cm}{3cm}
  20. \caption{\protect\lipsum[2]}
  21. \label{fig:foo}
  22. \end{figure}
  23.  
  24. \lipsum[3]
  25.  
  26. \end{document}


Since the »revtex4-1« class seems to be designed for articles submitted to the American Physical Society or the American Institute of Physics, the captions are designed exactly the way they want it. Why do you want to change them, then? (Or aren't you using the class to submit an article to them?)

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

vichome
Posts: 3
Joined: Wed Dec 19, 2012 11:24 pm

Postby vichome » Fri Dec 21, 2012 11:02 pm

Thanks, Clemens -- but I was unable to get the result using the code, even after numerous attempts.

  1. \makeatletter
  2. \renewcommand\@make@capt@title[2]{%
  3. \@ifx@empty\float@link{\@firstofone}{\expandafter\href\expandafter{\float@link}}%
  4. {\textbf{#1}}\@caption@fignum@sep#2\quad}%
  5. \makeatother


What I did was to put the code in the preample. I commented the previously used \caption but the other things remained the same, correct?
  1. (\begin{figure} ... \caption ... \end{figure})

LaTeX reacted to this by changing Figure 1--no full stop -- \quad to FIG. 1. But justification did not change to justified.

Could you please tell where I can find information on the \caption package for TeX Live 2011/2012 to read about the TeX Live inherent caption package?

Your message prompted me to just use \hfil to spread the words along the line so that the figure captions look like justified. I do need to understand how TeX Live's intrinsic \caption works, though, and would appreciate your advice on that.

Frohe Weinachten!

Victor

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Fri Dec 21, 2012 11:19 pm

vichome wrote:Thanks, Clemens -- but I was unable to get the result using the code, even after numerous attempts.

Could you then post a Infominimal working example (similar to what I posted, i.e., beginning with \documentclass and ending with \end{document}) so I (or someone else) can see what is going on?

vichome wrote:Could you please tell where I can find information on the \caption package for TeX Live 2011/2012 to read about the TeX Live inherent caption package?


There are in principle two main ways to find information on a package. The first: look on your own computer where the documentation is probably installed. A command line call of the following:
  1. texdoc caption

should open the caption documentation for instance. If it isn't there there's also http://texdoc.net:
  1. http://texdoc.net/pkg/caption

should also open the documentation.

Second there's always CTAN (the Comprehensive TeX Archive Network):
  1. http://www.ctan.org/pkg/caption


vichome wrote:Frohe Weinachten!

Thanks! Merry Christmas to you, too

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

vichome
Posts: 3
Joined: Wed Dec 19, 2012 11:24 pm

Postby vichome » Sat Dec 22, 2012 5:56 pm

Now your code works! Probably, I missed something when inserting it. Anyway, I have prepared an MWE and would put it on display -- it could be useful to others...

  1. \documentclass[twoside,rmp, ams]{revtex4-1}
  2. \usepackage{amsmath, amsfonts, amssymb}
  3. \usepackage{graphicx}
  4.  
  5. %%%%%%%%%%%%%%%%% Clemens (Latex Community)
  6. % \documentclass{revtex4-1} %%%%%%%%%%%%%
  7. % \usepackage[utf8]{inputenc} %%%%%%%%%%%%%
  8. % \usepackage[T1]{fontenc} %%%%%%%%%%%%%
  9. %
  10. % \usepackage{lipsum}% for dummy text %%%%%%%%%%%%%
  11.  
  12. % \makeatletter %%%%%%%%%%%%%
  13. % \renewcommand\@make@capt@title[2]{%
  14. % \@ifx@empty\float@link{\@firstofone}{\expandafter\href\expandafter{\float@link}}%
  15. % {\textbf{#1}}\@caption@fignum@sep#2\quad}%
  16. % \makeatother
  17. %%%%%%%%%%%%%%%%% Clemens (Latex Community)
  18.  
  19. \makeatletter
  20. \renewcommand\@make@capt@title[2]{%
  21. \@ifx@empty\float@link{\@firstofone}{\expandafter\href\expandafter{\float@link}}%
  22. {\textbf{#1}}\@caption@fignum@sep#2\quad}%
  23. \makeatother
  24.  
  25. \makeatletter
  26. \renewcommand{\fnum@figure}{\textbf{Figure~\thefigure}}
  27. \makeatother
  28.  
  29. \begin{document}
  30.  
  31. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
  32.  
  33. \begin{figure}[h]
  34. \rule{5cm}{3cm}
  35. \caption{Capt to be justif Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justified Caption to be justifiedCaption to be justifiedCaption to be justifiedCaption to be justifiedCaption to be justifiedCaption to be justifiedCaption to be justifiedCaption to be justified.}
  36. \end {figure}
  37.  
  38. \end{document}


Thanks a lot!


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests