Graphics, Figures & TablesTable & image

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
tpokala
Posts: 21
Joined: Wed Nov 10, 2010 6:13 pm

Table & image

Post by tpokala »

Hi, I have code

Code: Select all

\begin{figure*}[htbp]
  \centering
  \begin{tikzpicture}[scale=3]
    \tikzstyle{every node}=[draw,shape=circle];
    \path (0:0cm) node (v0) {$1$};
    \path (0:1cm) node (v1) {$2$};
    \path (70:1cm) node (v2) {$3$};
    \path (2*70:1cm) node (v3) {$4$};
    \path (3*70:1cm) node (v4) {$5$};
    \path (4*70:1cm) node (v5) {$6$};
    \draw (v0) -- (v1)
    (v1) -- (v2)
    (v2) -- (v3)
    (v3) -- (v4)
    (v4) -- (v5)
    (v5) -- (v1)
    (v0) -- (v2)
    (v0) -- (v3)
    (v0) -- (v4)
    (v0) -- (v5);
  \end{tikzpicture}
  
  \begin{tabular}{l|l|l|l|l|l|l}
			&1&2&3&4&5&6\\ \hline
		 1&0&1&1&1&1&1\\ \hline
		 2&1&0&1&0&0&1\\ \hline
		 3&1&1&0&1&0&0\\ \hline
		 4&1&0&1&0&1&0\\ \hline
		 5&1&0&0&1&0&1\\ \hline
		 6&1&1&0&0&1&0\\	
		\end{tabular}
  \caption{Przykładowy graf i jego macierz sąsiedztw}
  \label{fig:przykladowy-graf-i-jego-macierz-sasiedztw}
\end{figure*}
but I need to show both table and image in one line, not under/above. How can I do it? I tried decrease scale for tikz picture but no luck
Last edited by tpokala on Sat Jan 01, 2011 3:08 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Table & image

Post by torbjorn t. »

You have an empty line between the tikzpicture and tabular environments, and hence the table will be in a new paragraph. Remove the blank line and/or add some horizontal space between them.

By adding baseline=(current bounding box.center) as an option to the tikzpicture environment, and the optional parameter [c] to the tabular environment, the two are aligned by their centre points.

Code: Select all

\documentclass[a4paper]{article}
\usepackage{tikz}

\begin{document}
\begin{figure*}[htbp]
  \centering
  \begin{tikzpicture}[scale=2,baseline=(current bounding box.center)]
    \tikzstyle{every node}=[draw,shape=circle];
    \path (0:0cm) node (v0) {$1$};
    \path (0:1cm) node (v1) {$2$};
    \path (70:1cm) node (v2) {$3$};
    \path (2*70:1cm) node (v3) {$4$};
    \path (3*70:1cm) node (v4) {$5$};
    \path (4*70:1cm) node (v5) {$6$};
    \draw (v0) -- (v1)
    (v1) -- (v2)
    (v2) -- (v3)
    (v3) -- (v4)
    (v4) -- (v5)
    (v5) -- (v1)
    (v0) -- (v2)
    (v0) -- (v3)
    (v0) -- (v4)
    (v0) -- (v5);
  \end{tikzpicture}
  \hspace{1cm}
    \begin{tabular}[c]{l|l|l|l|l|l|l}
         &1&2&3&4&5&6\\ \hline
       1&0&1&1&1&1&1\\ \hline
       2&1&0&1&0&0&1\\ \hline
       3&1&1&0&1&0&0\\ \hline
       4&1&0&1&0&1&0\\ \hline
       5&1&0&0&1&0&1\\ \hline
       6&1&1&0&0&1&0\\   
      \end{tabular}
  \caption{Przykładowy graf i jego macierz sąsiedztw}
  \label{fig:przykladowy-graf-i-jego-macierz-sasiedztw}
\end{figure*}
\end{document}
P.S. Please provide complete, compilable, examples[1], it makes it easier for those helping.

[1] http://latex-community.org/forum/viewto ... =37&t=7878
tpokala
Posts: 21
Joined: Wed Nov 10, 2010 6:13 pm

Re: Table & image

Post by tpokala »

Great, thx for help
Post Reply