# How to make a caption (table and figure) left justified

How do I make my captions both for table and figures left aligned. I tried using \usepackage[justification=justified,singlelinecheck=false]{caption}. But the caption is aligned with the page and not with the figure or table.

\documentclass[journal]{IEEEtran}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage[justification=justified,singlelinecheck=false]{caption}

\begin{document}
\begin{figure}[h!]
\centering
\includegraphics[height=2.1in,width=3.3in]{FPR_PpuCmpr}
\caption{False Positive Rate (FPR) Vs $P_{pu}$ (Majority Rule) }
\label{figureFPR_PpuCmpr}
\end{figure}

\end{document}

• The big question here is "Why?". When you're submitting content to a journal for publication, they follow their own procedure of setting content so it is consistent with other articles published in the same journal. So why do you want this to be different? – Werner Jan 27 '16 at 19:10

When using the caption package with the IEEEtran class you receive the following package warning:

Package caption Warning: Unsupported document class (or package) detected,
(caption)                usage of the caption package is not recommended.
See the caption package documentation for explanation.


So let's not use caption.

You can set the image-and-caption inside a minipage of fixed width. This fixed width would match what you want the image width to be, and then set width=\linewidth for your \includegraphics. This will ensure that the image is the same width as the width specified for the minipage:

\documentclass[journal]{IEEEtran}
\usepackage{graphicx,lipsum}

\begin{document}

\lipsum[1]

\begin{figure}[h!]
\centering
\begin{minipage}{2.5in}
\includegraphics[height=2.1in,width=\linewidth]{example-image}
\caption{This is some figure caption}
\end{minipage}
\end{figure}

\lipsum[2]

\end{document}


When working with a table that you want the same to happen, you could use the varwidth package's varwidth environment; use \columnwidth as your "fixed-width specification". It's similar to minipage, but will shrink if the contents is narrower than specified.

It's easy to do it with the threeparttable environment, which measures the width of tables:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{fourier, erewhon}
\usepackage[justification=justified,singlelinecheck=false]{caption}
\usepackage{booktabs}
\usepackage{threeparttable}

\begin{document}
\vspace*{2cm}
\begin{table}[!h]
\centering
\begin{threeparttable}
\begin{tabular}{cc}
\toprule
A & B
\\ \midrule
11111111111111111 & 1111111111111111\\
22222222222222222 & 2222222222222222\\
33333333333333333 & 3333333333333333\\
44444444444444444 & 4444444444444444\\
55555555555555555 & 5555555555555555\\
66666666666666666 & 6666666666666666\\
\bottomrule
\end{tabular}
\caption{Caption caption caption caption\\
caption caption. }
\end{threeparttable}
\end{table}

\end{document}


• can it be used with figures also? – roshni Jan 27 '16 at 18:26
• The threeparttable package defines a measuredfigure environment. – Bernard Jan 27 '16 at 18:28