# The use of justification

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 8 at 12:20
• To format inline "code" in your question, delimit the code with grave accents, like code=0 – Steven B. Segletes Jan 8 at 12:26
• – Johannes_B Jan 8 at 12:40
• the caption and subcaption packages are not compatible with revtex package. see tex.stackexchange.com/questions/135718/…. – Zarko Jan 8 at 12:46
• 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 8 at 12:53

Use

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


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}


• why the +/- fil skips in left and rightskip? the default text justification simply uses 0pt there? – David Carlisle Jan 8 at 12:51
• Dear Steven B. Segletes, you in fact answered my question. Thank you very, very much for your answer. – Ad van der Ven Jan 8 at 12:52
• @DavidCarlisle As I explained, I tweaked what was in the caption package. It's black magic to me. – Steven B. Segletes Jan 8 at 12:53
• I think they could be \z@ with no difference in the output unless there is an fil glue added within the caption (the behaviour of \hspace{0pt plus 1fil}` in the presence of those settings is well defined but probably surprising:-) – David Carlisle Jan 8 at 12:56
• testing my suggestions?, you show such little faith! – David Carlisle Jan 8 at 12:58