1

I would like to center a figure made on Tikz. This figure has a specific size which is wider than \textwidth, and it needs to be centered. All options I see use \resibox or \makebox to center the figures. But I don't want to change the figure size. Are there any option or command to allow this?

Thanks very much in advance. Kind regards,

German

=== SOLUTION == As Mr @David Carlisle commented below, the solution is uncomment the \makebox and set the scaling to 0pt as follow:

\begin{figure}[h!]
\centering  
\newlength\figureheight 
\newlength\figurewidth 
\setlength\figureheight{6cm} 
\setlength\figurewidth{1.2\linewidth}
\begingroup
    \fontsize{8}{\baselinestretch}\selectfont
    \makebox[0pt][c]{
    \input{VoltFRFFreq.tikz}
    %}
\endgroup
\caption{A plot of a sphere}
\label{fig.freq}
\end{figure}

Thanks again to all people!!

-- EDIT's --- P.D.-I forgot to mention I use XeLaTeX, I hope it helps. Kind regards, P.D.D- The code is

\begin{figure}[h!]
\centering  
\newlength\figureheight 
\newlength\figurewidth 
\setlength\figureheight{6cm} 
\setlength\figurewidth{1.2\linewidth}
\begingroup
        \fontsize{8}{\baselinestretch}\selectfont
        %\makebox[\figurewidth][c]{
    \input{VoltFRFFreq.tikz}
    %}
\endgroup
\caption{A plot of a sphere}
\label{fig.freq}
\end{figure}
Ger
  • 187

2 Answers2

2

uncomment your \makebox

  %\makebox[\figurewidth][c]{

but change the specified width to 0pt instead of \figurewidth

David Carlisle
  • 757,742
0

since your figure is wider than the text width, you want to make it look to latex like it is narrower. here's one possibility (just the group with the figure):

\noindent\hss
\begingroup
        \fontsize{8}{\baselinestretch}\selectfont
    \input{VoltFRFFreq.tikz}
\endgroup
\hss\par
  • Hi Barbara

    The code you propose gives me an error: ! Infinite glue shrinkage found in a paragraph. I forgot to mention I use XeLaTeX, I hope it helps.

    Kind regards,

    – Ger Jun 24 '16 at 18:19
  • david's answer is more "real latex". so go with that. this one could be salvaged by changing the \hss to something like \hskip -.15\linewidth (or, better, \hspace{-.15\linewidth}) but the latex \makebox with 0 width does the "right thing". xelatex doesn't matter in this situation. – barbara beeton Jun 24 '16 at 19:03