1

This question already has an answer here:

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}

marked as duplicate by David Carlisle floats Jun 24 '16 at 19:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @barbarabeeton That's right! Thanks very much!! – Germán Martínez Jun 24 '16 at 18:01
  • 1
    for future reference, shouldn't the question be restated as "Centering box wider than \textwidth" or so ? – Christoph Frings Jun 24 '16 at 18:52
  • 1
    @ChristophFrings -- excellent suggestion, but there's already a question with that heading: Center figure that is wider than \textwidth so this one should probably be considered a duplicate. – barbara beeton Jun 24 '16 at 19:09
2

uncomment your \makebox

  %\makebox[\figurewidth][c]{

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

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, – Germán Martínez 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

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