2

I used the following Latex source file:

\RequirePackage{lineno}   
\documentclass[aps,prl]{revtex4}
\usepackage{graphicx}% Include figure files   
\usepackage{epstopdf}   % this graphic package converts eps to pdf for easier usage of eps files  
\usepackage{lpic}  
\usepackage{amsmath,amssymb}
\usepackage{nicefrac}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}   
\usepackage{xcolor} 
\usepackage{listingsutf8}  
\usepackage[section]{placeins}  
\lstset{mathescape=true} 
\newcommand{\ket}[1]{\left|{#1}\right\rangle} 
\newcommand{\bra}[1]{\left\langle{#1}\right|} 
\newcommand{\is}[1]{{\color{blue} #1}}
\usepackage{subcaption}

\captionsetup{compatibility=false}  
\begin{document}

\textbf{Corresponding author information}\\
Ad van der Ven, email: a.vanderven@pwo.ru.nl

\begin{figure}

  \begin{subfigure}{0.50\textwidth}

{\bf Figure}

  \caption{Based on the observed data sets}

  \label{fig:RegressionFixedObservedN4451}

\end{subfigure}

\captionsetup{justification=raggedright,singlelinecheck=false}

\caption{Regression plot for the fixed condition of the ACT (N = 445). The
 x-axis represents the natural logarithm of the absolute value of the minimum
 residual score belonging to the sequence of 14 consecutive bars with the
 smallest MSE. The y-axis represents the smallest MSE. The top line is the
 line $y = 2x + \ln{10}$. The bottom line is the line $y = 2x-\ln{10}$. The
 line exactly in between is the line $y=2x$.}
\label{fig:observedfixedcondion}

\end{figure}

\end{document}

However I do not want to have justification=raggedright nor justification=raggedleft. I simply want the caption aligned left and right. It seems justification does not have that option. I could not find an answer at 'Questions that may already have your answer'.

  • Welcome to the site. To include source code in your question, highlight the code block and click the {} icon above the edit box. This will indent each line of code by 4 spaces in the edit box, which has the visual effect of rendering like code in the html page. – Steven B. Segletes Jan 08 '19 at 12:20
  • To format inline "code" in your question, delimit the code with grave accents, like \code=0`` – Steven B. Segletes Jan 08 '19 at 12:26
  • Related: https://tex.stackexchange.com/questions/468942/avoid-automatic-centering-of-caption – Johannes_B Jan 08 '19 at 12:40
  • Hi Steven B. Segletes, Thanks for repairing the layout of my question. – Ad van der Ven Jan 08 '19 at 12:40
  • I wouldn't bother about formatting. Revtex folks will restyle anyway if the current output does not fit their needs. – Johannes_B Jan 08 '19 at 12:41
  • Dear Johannes_B The related site you suggested did not answer my question. I do not know what you mean by 'Revtex folks' The source file which I gave is part of a paper which I am going to submit to a scientific journal and their require nicely aligned captions. – Ad van der Ven Jan 08 '19 at 12:42
  • 1
    the caption and subcaption packages are not compatible with revtex` package. see https://tex.stackexchange.com/questions/135718/caption-automatically-centered-in-a-revtex-document. – Zarko Jan 08 '19 at 12:46
  • Dear Zanko, How should I rewrite my source file? – Ad van der Ven Jan 08 '19 at 12:48
  • 2
    If you are submitting to a journal using revtex then, as author, you should not restyle the document, the whole point of a publisher class like revtex is to remove choice from the author and enforce the publication style. – David Carlisle Jan 08 '19 at 12:53

2 Answers2

1

Use

[...]
\usepackage{ragged2e}
\usepackage{subcaption}   
\DeclareCaptionJustification{justified}{\justifying}
\captionsetup{compatibility=false,justification=justified}  
[...]

enter image description here

0

The formatting (line-centered caption) arises from the revtex4 document class. Here, I create my own caption justification option with \DeclareCaptionJustification{myjust}{\fulljustify}.

I defined \fulljustify by starting with the caption package definition of \centerlast and modifying it to get rid of the centered last line.

The option justification=justified, which would normally work in other document classes, is actually a null option, adding zero additional code, thus assuming the document class default is fully justified (which it is not for revtex4).

\RequirePackage{lineno}
\documentclass[aps,prl]{revtex4}
\usepackage{graphicx}% Include figure files
\usepackage{epstopdf}   % this graphic package converts eps to pdf for easier usage of eps files
\usepackage{lpic}
\usepackage{amsmath,amssymb}
\usepackage{nicefrac}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{listingsutf8}
\usepackage[section]{placeins}
\lstset{mathescape=true}
\newcommand{\ket}[1]{\left|{#1}\right\rangle}
\newcommand{\bra}[1]{\left\langle{#1}\right|}
\newcommand{\is}[1]{{\color{blue} #1}}
\usepackage{subcaption}
\captionsetup{compatibility=false}
\DeclareCaptionJustification{myjust}{\fulljustify}

\makeatletter
\providecommand\fulljustify{%
  \let\\\@centercr
  \leftskip\z@%
  \rightskip\z@%
  \parfillskip\z@\@plus 1fill\relax%
}
\makeatother

\begin{document}
\textbf{Corresponding author information}\\
Ad van der Ven, email: a.vanderven@pwo.ru.nl
\begin{figure}
  \begin{subfigure}{0.50\textwidth}
{\bf Figure}
  \caption{Based on the observed data sets}
  \label{fig:RegressionFixedObservedN4451}
\end{subfigure}
\captionsetup{justification=myjust,singlelinecheck=false}
\caption{Regression plot for the fixed condition of the ACT (N = 445). The
 x-axis represents the natural logarithm of the absolute value of the minimum
 residual score belonging to the sequence of 14 consecutive bars with the
 smallest MSE. The y-axis represents the smallest MSE. The top line is the
 line $y = 2x + \ln{10}$. The bottom line is the line $y = 2x-\ln{10}$. The
 line exactly in between is the line $y=2x$.}
\label{fig:observedfixedcondion}
\end{figure}
\end{document}

enter image description here