2

I'm trying to find the easiest way to create Tikz diagrams mixed with tables.

Such as these: enter image description here

or

enter image description here

https://tex.stackexchange.com/questions/400557/how-to-add-connected-graphs-to-a-table

Writing properly all this code can become quite complex and prone to error.

There are several tools to help you create TikZ diagrams, such as TikzEdt.

enter image description here

One could try to create TikZ diagrams with that tools and import them to your main tex document. But it will be difficult to make a complex diagram properly match the text, tables and other figures.

An alternative would be to create the tables with Lyx, and import it from TikzEdt to start drawing above it.

I've tried inserting the table code in the preample (TikzEdt) or in its main code window but I haven't been able to get it.

enter image description here

In its settings -> compiler options it has this code:

\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usepackage[margin=0cm,nohead]{geometry}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows}
% needed for BB
\usetikzlibrary{calc}

enter image description here

Imagine I want to add this table:

\documentclass{article}
\begin{document}
\begin{tabular}{ccc}
ID & Ord & Event\\
\hline 
Ana & 1 & A\\
Tom & 1 & A\\
Tom & 2 & B\\
Tom & 3 & D\\
\end{tabular}
\end{document}

I've tried modyfing the code as:

\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usepackage[margin=0cm,nohead]{geometry}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows}
% needed for BB
\usetikzlibrary{calc}
\begin{document}
\begin{tabular}{ccc}
ID & Ord & Event\\
\hline 
Ana & 1 & A\\
Tom & 1 & A\\
Tom & 2 & B\\
Tom & 3 & D\\
\end{tabular}
\end{document}

but it doesn't produce any result. I guess because it tries to add a begin{document} twice.

I've also tried leaving the preamble as is and adding the table on the main window.

\begin{tabular}{ccc}
ID & Ord & Event\\
\hline 
Ana & 1 & A\\
Tom & 1 & A\\
Tom & 2 & B\\
Tom & 3 & D\\
\end{tabular}
\begin{tikzpicture}
\end{tikzpicture}

But again it doesn't work.

How can I do it?

Or what other GUI tool can I use able to draw TikZ arrows and simple symbols onto a preexistent document or able to create tables?

skan
  • 7,423
  • 14
  • 59
  • 96

1 Answers1

1

I was looking for a solution of the same problem and found this very useful link! It contains the following code:

\begin{tikzpicture}
\matrix[ampersand replacement=\&] {
    \node (species1) [shape=rectangle,draw] {
        \begin{tabular}{c c c}
            \multicolumn{3}{c}{{Species 1}} \\
            \colorbox{red}{G1t} & \colorbox{blue}{G2a} & \colorbox{green}{G3t} \\
            \colorbox{blue}{G1b} & \colorbox{red}{G2b} & 
        \end{tabular}
    };
    \& 
    \node {b}; \\
    \node {c}; \& \node {d}; \\
};
\end{tikzpicture}

I've just tried it myself, and it does what it says on the tin: it lets you use tabular inside a tikz node. No extra packages or other things to be included in the header. You could then move the node around and use it to make diagrams like you wanted.

EdvinW
  • 111
  • 3