如何在LaTeX中绘制图形? [英] How to draw a graph in LaTeX?

查看:253
本文介绍了如何在LaTeX中绘制图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,让我说我正在使用LyX,尽管我使用ERT没问题.

First of all, let me say I'm using LyX, though I have no problem using ERT.

第二,在Latex中绘制这样一个简单图形的最简单方法是什么?

Secondly, what is the most simplest way to draw a simple graph like this in Latex?

我看过一些带有图形的文档,也看到了一些示例,但我想不出如何绘制简单的图形-我需要什么包,等等?

I've seen some documents with graphs and I've seen some examples, but I couldn't figure out how to just draw a simple graph - what packages do I need, etc?

推荐答案

TikZ可以做到这一点.

TikZ can do this.

快速演示:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  [scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
  \node (n6) at (1,10) {6};
  \node (n4) at (4,8)  {4};
  \node (n5) at (8,9)  {5};
  \node (n1) at (11,8) {1};
  \node (n2) at (9,6)  {2};
  \node (n3) at (5,5)  {3};

  \foreach \from/\to in {n6/n4,n4/n5,n5/n1,n1/n2,n2/n5,n2/n3,n3/n4}
    \draw (\from) -- (\to);

\end{tikzpicture}

\end{document}

产生:

更多示例@ http://www.texample.net/tikz/examples/标签/图形/

有关TikZ的更多信息: http://sourceforge.net/projects/pgf/猜猜还会有安装指南.

More information about TikZ: http://sourceforge.net/projects/pgf/ where I guess an installation guide will also be present.

这篇关于如何在LaTeX中绘制图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆