1

I am trying to center the caption of a figure in latex.

\begin{wrapfigure}{r}{0.50 \textwidth}
  \vspace{-20pt}
  \begin{center}
    \resizebox{0.5\linewidth}{!}{ \subimport{./Figures/}{vector.tex}}
  \vspace{-10pt}
   \captionsetup{margin=1.8cm}
  \caption{Graphic representation of vectors}
  \label{fig:vectors}
    \end{center}
  \vspace{-10pt}
\end{wrapfigure}

and my figure is done in another file as follows

\documentclass[float=false, crop=false]{standalone}
\usepackage[subpreambles=true]{standalone}
\usepackage{import}
\begin{document}
\begin{tikzpicture}
  \draw[thin,gray!40] (-2,-2) grid (2,2);
  \draw[line width=2pt,blue,-stealth](0,0)--(1,1) node[anchor=south west]{$\boldsymbol{}$};
  \draw[line width=2pt,red,-stealth](-2,0)--(-1,1) node[anchor=south west]{$\boldsymbol{}$};
  \draw[line width=2pt,green,-stealth](-1,-1)--(-2,-2) node[anchor=north east]{$\boldsymbol{}$};
  \draw[line width=2pt,magenta,-stealth](2,0)--(1,-1) node[anchor=north east]{$\boldsymbol{}$};
\end{tikzpicture}
\end{document}

I get this

I would like to have the caption center and the figure a little bit larger so the figure is larger of the caption. I also would like that the text continues around the figure and not only in the left part of the figure.

Thanks

0

like this?

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{caption}

\usepackage{lipsum}

\begin{document}
\lipsum [2]
\begin{wrapfigure}{r}{0.50 \textwidth}
\centering
\begin{tikzpicture}% image you can insert with \input{<path>/<file name>}
    [scale=1.2,% increased image
    L/.style = {draw=#1, line width=2pt,-stealth}% for simplified imnage code
    ]
  \draw[thin,gray!40] (-2,-2) grid (2,2);
  \draw[L=blue]     ( 0,0)  -- ( 1,1);
  \draw[L=red]      (-2,0)  -- (-1,1);
  \draw[L=green]    (-1,-1) -- (-2,-2);
  \draw[L=magenta]  (2,0)   -- (1,-1);
\end{tikzpicture}
   \captionsetup{margin=1.2cm}
  \caption{Graphic representation of vectors}
  \label{fig:vectors}
\end{wrapfigure}
\lipsum[1]
\end{document}

note: tikzpicture as tex file can not be scaled by \resizebox. if you like increase it size, you should use scale in image code or include image as pdf file and than use includegraphics[width=<length>]{<path>/<image name>}.

or you mean to have caption in centering justification?

enter image description here

for above caption i use

\captionsetup{margin=1cm,justification=centering}
| 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.