0

I was looking how to resize tikzpicture, and saw this accepted answer here

Specifying the width and height of a tikzpicture

But the code posted there do not work any more.

Here is the same exact code copied here from the above

\documentclass [tikz] {standalone}

\begin {document}
    \begin {figure}
        \centering
        \resizebox {\columnwidth} {!} {
            \begin {tikzpicture}
                \node [draw] (my node 1) {my node 1};
                \node [draw, anchor = west] (my node 2) at (my node 1.east) {centro};
                \node [draw, anchor = west] at (my node 2.east) {my node 3};
            \end {tikzpicture}
        }
    \end {figure}
\end {document}

When I compile it, the error is

lualatex foo2.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
 restricted system commands enabled.
(./foo2.tex
LaTeX2e <2018-12-01>
.
.
.
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Improper \prevdepth.
\newpage ...everypar {}\fi \par \ifdim \prevdepth
                                                  >\z@ \vskip -\ifdim \prevd...

l.12         }

? X
 1704 words of node memory still in use:
   29 hlist, 1 rule, 1 disc, 1 local_par, 2 dir, 52 glue, 8 kern, 1 penalty, 22
 glyph, 89 attribute, 52 glue_spec, 89 attribute_list, 2 temp, 3 if_stack, 1 wr
ite, 41 pdf_literal, 7 pdf_colorstack nodes
   avail lists: 2:2,5:11

warning  (pdf backend): no pages of output.
Transcript written on foo2.log.

The question is : What changes is needed to make it compile? I am using lualatex with TL 2019.

  • The code has never worked. I guess the author tried with a standard class and then wrapped the code in standalone “for simplicity” without even trying it. I changed it. I guess you can remove the question. – egreg May 28 at 9:06
1

I am not sure it makes sense to use standalone (that is designed to make the page as wide as the content) and then specify the content is as wide as the page, nor does a float like figure do anything useful in standalone The posted code certainly hasn't worked since texlive 2016 and i don't see how it could have worked before.

scaling text like this is usually a bad idea, but this works

\documentclass{article}
\usepackage{tikz}
\begin {document}
    \begin {figure}
        \centering
        \resizebox {\columnwidth} {!} {%%%%
            \begin {tikzpicture}
                \node [draw] (my node 1) {my node 1};
                \node [draw, anchor = west] (my node 2) at (my node 1.east) {centro};
                \node [draw, anchor = west] at (my node 2.east) {my node 3};
            \end {tikzpicture}%%%
        }
    \end {figure}
\end {document}

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.