2

I want to draw some 3D cubes. I found a useful script on how to draw parallelepiped and cube with latex?.

The part of code is as follows,

\documentclass[border=5pt, multi, tikz]{standalone}
\usetikzlibrary{quotes,arrows.meta}
\tikzset{
  annotated cuboid/.pic={
    \tikzset{%
      every edge quotes/.append style={midway, auto},
      /cuboid/.cd,
      #1
    }
    \draw [every edge/.append style={pic actions, densely dashed, opacity=.5}, pic actions]
    (0,0,0) coordinate (o) -- ++(-\cubescale*\cubex,0,0) coordinate (a) -- ++(0,-\cubescale*\cubey,0) coordinate (b) edge coordinate [pos=1] (g) ++(0,0,-\cubescale*\cubez)  -- ++(\cubescale*\cubex,0,0) coordinate (c) -- cycle
    (o) -- ++(0,0,-\cubescale*\cubez) coordinate (d) -- ++(0,-\cubescale*\cubey,0) coordinate (e) edge (g) -- (c) -- cycle
    (o) -- (a) -- ++(0,0,-\cubescale*\cubez) coordinate (f) edge (g) -- (d) -- cycle;
    \path [every edge/.append style={pic actions, |-|}]
    (b) +(0,-5pt) coordinate (b1) edge ["\cubex \cubeunits"'] (b1 -| c)
    (b) +(-5pt,0) coordinate (b2) edge ["\cubey \cubeunits"] (b2 |- a)
    (c) +(3.5pt,-3.5pt) coordinate (c2) edge ["\cubez \cubeunits"'] ([xshift=3.5pt,yshift=-3.5pt]e)
    ;
  },
  /cuboid/.search also={/tikz},
  /cuboid/.cd,
  width/.store in=\cubex,
  height/.store in=\cubey,
  depth/.store in=\cubez,
  units/.store in=\cubeunits,
  scale/.store in=\cubescale,
  width=10,
  height=10,
  depth=10,
  units=cm,
  scale=.1,
}
\begin{document}
\begin{tikzpicture}
  \pic {annotated cuboid};
  \pic [fill=magenta, text=blue, draw=blue] at (5,0) {annotated cuboid={width=30, height=5, depth=10}};
  \pic [fill=green, text=green!50!black, draw=green!25!black] at (5,-2) {annotated cuboid={width=6, height=20, depth=15, units=mm}};
  \pic at (1,-3) {annotated cuboid={width=150, height=200, depth=250, scale=.01, units=m}};
  \pic [fill=cyan, text=blue!75!cyan, draw=blue!75!cyan] at (-3,-2) {annotated cuboid={width=15, height=18, depth=13.5, units=}};
\end{tikzpicture}
\end{document}

But unfortunately, I found I cannot use \usetikzlibrary{quotes,arrows.meta}' because of the error! I can't find file tikzlibraryarrows.meta.code.tex'.

I use Texmaker on Ubuntu 14.04.

The commands I used are:

  1. apt-get install texlive

  2. aptitude install pgf

  3. texhash

The solution is I download the new version of PGF (zip file). I unzip it and then use texhash. This is for my case.

Vivian
  • 21
  • 1
    Probably your installation of TeX is too old and you only have PGF 2.1 rather than 3+. The recommended course would be to remove your distro's TeX Live packages and to install vanilla TeX Live from upstream. – cfr May 05 '16 at 00:34
  • 2
    @cfr, Thanks! I update PGF. And the problem is solved. – Vivian May 05 '16 at 09:21
  • 4
    I'm voting to close this question as off-topic because the OP has outdated PGF isnatallation. With its update he solve his problem. – Zarko Oct 01 '16 at 14:50

0 Answers0