1

Could you help me I want to remove caption to put it at the left margin for any environment like this enter image description here

I know it is not a good way any advice ? Thank you. This is my MWE:

\documentclass[12pt,a4paper,twoside,openany]{book}

\usepackage{etex}

\usepackage[utf8]{inputenc}

\usepackage[OT1,T1]{fontenc}

\usepackage{amsmath,mathtools}

\usepackage{amsfonts}
\usepackage{bm}
\usepackage{amssymb}

\usepackage{libertine}

\usepackage{graphicx}

\usepackage{xcolor}

\usepackage[framemethod=default]{mdframed}

\usepackage[left=3cm,right=3cm,top=2 cm,bottom=2 cm]{geometry}

\usepackage{array}

\usepackage{colortbl}

\usepackage{booktabs} 

\definecolor{monvert}{RGB}{0,0,166}
\definecolor{MOnvert}{RGB}{220,85,22} 
\definecolor{Monvert}{RGB}{122,160,175}
\usepackage[frenchb]{babel}

\frenchbsetup{StandardLists=true}

\usepackage{caption}

\usepackage{rotating}

%macros
\makeatletter

\renewcommand{\fnum@figure}{\color{Monvert}\underline{\small\textbf{\figurename~\thefigure}}}

\makeatother

\DeclareCaptionFormat{llap}{\llap{#1#2}\\ \hspace*{-2.2 cm}%
\begin{minipage}{0.25\textwidth}%
#3   
 \end{minipage}%
}
\captionsetup{format=llap,labelsep=quad,singlelinecheck=no}

 \begin{document}

\begin{table}[h]
 \arrayrulecolor{Monvert}  
\scalebox{0.9}{%
\begin{tabular}{lccccc}
\toprule
&\textbf{Source de variation} & \textbf{\textit{d.d.l}} & \textbf{Somme des carrés}&\textbf{Carré moyen}$\bm{CM= \frac{SC}{d.d.l}}$&\textbf{Rapport }$F$\\
\midrule
&Inter facteur $G$& $K-1$ & $\sum\limits^{K}_{j=1}n_j(\bar{X}_j -\bar{X})^2 = SC_G$&$CM_G =\dfrac{SC_G}{K-1}$&\\
&Intra (résidu)&$N-K$ & &&\\
&Total & $N-1$ & &&\\
\bottomrule
\end{tabular}}
\caption{test d'une figure qui s'allonge et s'allonge et s'allonge jusqu'où ?}
\end{table}
\end{document}
  • Error Undefined control sequence \bm? – Salim Bou Aug 26 '15 at 15:54
3

Package floatrow provide command \floatbox

Here we use \floatbox[<preamble>]{<captype>}[<width>]{caption}{object} were:

  • In the <preamble> we have \capbeside which places caption beside float, \thisfloatsetup which define some settings for the float.
  • With <captype> we put table.

  • \FBwidth option in the width argument allows usage of natural width of float.


Code

\documentclass[12pt,a4paper,twoside,openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[OT1,T1]{fontenc}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{libertine}
\usepackage{graphicx}
\usepackage{bm}
\usepackage{xcolor}
\usepackage[left=3cm,right=3cm,top=2 cm,bottom=2 cm]{geometry}
\usepackage{array}
\usepackage{colortbl}
\usepackage{booktabs} 
\definecolor{monvert}{RGB}{0,0,166}
\definecolor{MOnvert}{RGB}{220,85,22} 
\definecolor{Monvert}{RGB}{122,160,175}
\usepackage[frenchb]{babel}
\frenchbsetup{StandardLists=true}
\usepackage{caption}
\usepackage{floatrow}

%macros
\makeatletter
\renewcommand{\fnum@figure}{\color{Monvert}\underline{\small\textbf{\figurename~\thefigure}}}
\makeatother

\DeclareCaptionFormat{llap}{\llap{#1#2}\\ \hspace*{-2.2 cm}%
\begin{minipage}{0.25\textwidth}%
#3   
 \end{minipage}%
}


\DeclareCaptionLabelFormat{underlcap}{\underline{#1 #2}}
\DeclareCaptionFont{Monvert}{\color{Monvert}}
\captionsetup{format=llap,labelsep=quad,singlelinecheck=no,labelfont=Monvert,labelformat=underlcap}

\begin{document}

\renewcommand{\arraystretch}{2}
\setlength{\tabcolsep}{3pt}

\begin{table}[h]

\floatbox%
[{\capbeside\thisfloatsetup{capbesideposition={left,top},capbesidewidth=1.4cm}}]{table}
[\FBwidth]
{%
\scalebox{0.8}{\caption{\footnotesize test d'une figure qui s'allonge et s'allonge et s'allonge jusqu'où ?}\label{tab:test}}
}
{%
\arrayrulecolor{Monvert}  

\scalebox{0.8}{%
\begin{tabular}{lcccc}
\toprule
\textbf{Source de variation} & \textbf{\textit{d.d.l}} & \textbf{Somme des carrés}&\textbf{Carré moyen} {\scriptsize $\bm{CM= \frac{SC}{d.d.l}}$}&\textbf{Rapport }$F$\\
\midrule
Inter facteur $G$& $K-1$ & $\sum\limits^{K}_{j=1}n_j(\bar{X}_j -\bar{X})^2 = SC_G$&$CM_G =\dfrac{SC_G}{K-1}$&\\
Intra (résidu)   & $N-K$ & &  &\\
Total            & $N-1$ & &  &\\
\bottomrule
\end{tabular}}
}
\end{table}

\end{document}

Result

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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