1

This is my code:

\usemodule[tikz]
\usetikzlibrary{positioning,shapes}

\starttext
  \tikzset{
    cflow/.style={draw=black, ellipse, text centered, minimum width=1cm},
    arr/.style = {->,>=stealth},
  }
  \startfloatcombination[distance=10pt]
    \startplacetable[force,title={My Table}]
      \starttable[|l|l|l|l|l|l|l|l|l|l]
        \NC P \VL f1 \NC f2 \NC f3 \NC f4 \NC f5 \NC f6 \NC f7 \NC f8 \NC f9 \AR
        \HL \NC A \VL c \NC b \NC c \NC - \NC - \NC - \NC - \NC a \NC - \AR
      \stoptable
    \stopplacetable
    \startplacefigure[force,title={My Graph}]
      \starttikzpicture
        \node[cflow] (f1) {f1};
        \node[cflow,right=of f1] (f8) {f8};
        \node[cflow,right=of f8] (f2) {f2};
        \node[cflow,below=of f1] (f4) {f4};
        \node[cflow,below=of f8] (f6) {f6};
        \node[cflow,below=of f2] (f5) {f5};
        \node[cflow,below=of f4] (f9) {f9};
        \node[cflow,below=of f6] (f7) {f7};
        \node[cflow,below=of f5] (f3) {f3};

        \draw[arr] (f1) -- (f4);
        \draw[arr] (f1) -- (f6);
        \draw[arr] (f2) -- (f5);
        \draw[arr] (f3) -- (f7);
        \draw[arr] (f4) -- (f9);
        \draw[arr] (f6) to[bend left] (f7);
        \draw[arr] (f7) to[bend left] (f6);
        \draw[arr] (f8) -- (f2);
      \stoptikzpicture
    \stopplacefigure
  \stopfloatcombination
\stoptext

It yields:

Why is the second caption misplaced? How can I fix this?

  • This is an old "bug" that I had reported to the pgf mailing list in Oct 2009: see this thread for details. – Aditya Dec 23 '16 at 19:27
1

I am not so sure what is going on under the hood, but you have to wrap the tikzpicture inside a framed. Actually, \hbox suffices, but framed is semantically nicer. I guess it has to do with the fact that TeX is in vmode at that point and simply wraps the tikzpicture into a vbox of width \textwidth.

Furthermore, the syntax for force is wrong, it has to be location={force}. However, in this setting it has no effect and I removed it.

\usemodule[tikz]
\usetikzlibrary{positioning,shapes}

\starttext
  \tikzset{
    cflow/.style={draw=black, ellipse, text centered, minimum width=1cm},
    arr/.style = {->,>=stealth},
  }
  \startfloatcombination[distance=10pt]
    \startplacetable[title={My Table}]
      \starttable[|l|l|l|l|l|l|l|l|l|l]
        \NC P \VL f1 \NC f2 \NC f3 \NC f4 \NC f5 \NC f6 \NC f7 \NC f8 \NC f9 \AR
        \HL \NC A \VL c \NC b \NC c \NC - \NC - \NC - \NC - \NC a \NC - \AR
      \stoptable
    \stopplacetable
    \startplacefigure[title={My Graph}]
      \startframed[frame=off,offset=none]
        \starttikzpicture
          \node[cflow] (f1) {f1};
          \node[cflow,right=of f1] (f8) {f8};
          \node[cflow,right=of f8] (f2) {f2};
          \node[cflow,below=of f1] (f4) {f4};
          \node[cflow,below=of f8] (f6) {f6};
          \node[cflow,below=of f2] (f5) {f5};
          \node[cflow,below=of f4] (f9) {f9};
          \node[cflow,below=of f6] (f7) {f7};
          \node[cflow,below=of f5] (f3) {f3};

          \draw[arr] (f1) -- (f4);
          \draw[arr] (f1) -- (f6);
          \draw[arr] (f2) -- (f5);
          \draw[arr] (f3) -- (f7);
          \draw[arr] (f4) -- (f9);
          \draw[arr] (f6) to[bend left] (f7);
          \draw[arr] (f7) to[bend left] (f6);
          \draw[arr] (f8) -- (f2);
        \stoptikzpicture
      \stopframed
    \stopplacefigure
  \stopfloatcombination
\stoptext

enter image description here


If you don’t want to take care to wrap the tikzpicture into framed everytime you are in vmode, you can also adjust the definition of \start...\stoptikzpicture.

\unprotect

\let\old_start_tikz_picture=\starttikzpicture
\let\old_stop_tikz_picture =\stoptikzpicture

\newconditional\tikz_picture_started_in_vmode

\starttexdefinition unexpanded starttikzpicture
  \setfalse\tikz_picture_started_in_vmode
  \ifvmode
    \startframed[frame=off,offset=none]
    \settrue\tikz_picture_started_in_vmode
  \fi
  \old_start_tikz_picture
\stoptexdefinition

\starttexdefinition unexpanded stoptikzpicture
  \old_stop_tikz_picture
  \ifconditional\tikz_picture_started_in_vmode
    \stopframed
  \fi
\stoptexdefinition

\protect
| improve this answer | |
  • A \dontleavehmode should also suffice – Aditya Dec 23 '16 at 19:27
  • @Aditya Unfortunately no. This was the first thing I tried as I was thinking that the tikzpicture does not interrupt vmode but it is not the case. Only \hbox{...} (or other boxes) work. – Henri Menke Dec 23 '16 at 19:57

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.