按类别列出问题

Mathematics


软件 >> TeX >> PGF
Questions in category: PGF (PGF).

1

[PGF]直线(线段)的画法

Posted by haifeng on 2012-04-12 12:44:44 last update 2012-04-12 14:12:27 | Answers (0) | 收藏

1. 直接指定坐标, 然后使用\draw命令将它们连接起来.

\begin{tikzpicture}
\draw (0,0) -- (2,1);
\end{tikzpicture}

2. 但有时, 对于端点若给定名称, 如线段 $AB$, 则更容易理解, 并且有利于进一步使用它们.

\begin{tikzpicture}
\coordinate (A) at (0,0);% 定义 A 点的坐标是 (0,0)
\coordinate (B) at (2,1);
\draw[blue] (A) -- (B);
\end{tikzpicture}

3. 如果需要在端点旁标记 $A$, $B$, 并使用某种颜色, 则可以对\coordinate命令添加如下选项.

\begin{tikzpicture}
\coordinate [label=left:\textcolor{blue}{$A$}] (A) at (0,0);
\coordinate [label=right:\textcolor{blue}{$B$}] (B) at (1.25,0.25);
\draw[blue] (A) -- (B);
\end{tikzpicture}

A B

2

[TikZ]三阶行列式的对角线法则

Posted by haifeng on 2011-08-19 22:01:08 last update 2011-08-19 22:01:08 | Answers (0) | 收藏

\documentclass{article}

\usepackage{tikz}
\begin{document}

\begin{tikzpicture}%[scale=3]
\draw[very thick] (-1.5,1.5) -- (-1.5,-1.5);
\draw[very thick] (1.5,1.5) -- (1.5,-1.5);
%-----------------------------
\draw[blue] (-1,1) -- (2,-1.6);
\draw[blue] (0,1) -- (1.5,-0.5);
\draw[blue] (1,1) -- (2,0);
\draw[blue] (-1,0) -- (0.5,-1.5);
\draw[blue] (-1,-1) -- (0,-2);
\draw[blue,rotate=45](1.414,-1.414) arc (360:180:1.06 and 0.5);
\draw[blue,rotate=45](-1.414,-1.414) arc (180:360:1.06 and 0.5);
%-----------------------------
\draw[red,dashed] (1,1) -- (-2,-1.6);
\draw[red,dashed] (0,1) -- (-1.5,-0.5);
\draw[red,dashed] (-1,1) -- (-2,0);
\draw[red,dashed] (1,0) -- (-0.5,-1.5);
\draw[red,dashed] (1,-1) -- (0,-2);
\draw[red,dashed,rotate=45](-1.414,1.414) arc (90:270:0.5 and 1.06);
\draw[red,dashed,rotate=45](-1.414,-1.414) arc (270:90:0.5 and 1.06);
%-----------------------------
\path (-1,1) node [fill=white]{\color{orange} $a_{11}$}
       (0,1) node [fill=white]{\color{orange} $a_{12}$}
       (1,1) node [fill=white]{\color{orange} $a_{13}$}
      (-1,0) node [fill=white]{\color{orange} $a_{21}$}
       (0,0) node [fill=white]{\color{orange} $a_{22}$}
       (1,0) node [fill=white]{\color{orange} $a_{23}$}
     (-1,-1) node [fill=white]{\color{orange} $a_{31}$}
      (0,-1) node [fill=white]{\color{orange} $a_{32}$}
      (1,-1) node [fill=white]{\color{orange} $a_{33}$};

\end{tikzpicture}

\end{document}

3

TiKZ 简介

Posted by haifeng on 2011-08-18 16:55:52 last update 2011-08-18 22:22:04 | Answers (0) | 收藏

TikZ 是 PGF 中的一个宏包, 用于绘图. TikZ 跟 Unix 一样, 意思是 TikZ ist kein Zeichenprogramm. 它们都是由 Till Tantau 教授所开发的. TikZ 是 PGF 的前端, 提供了比较简单的语法, 使得相对于 PGF 来得更为好用.

下面是在 LaTeX 中使用 TikZ 作图的一个例子

LaTeX

\documentclass{article}
\usepackage{tikz}
\begin{document}
We are working on
\begin{tikzpicture}
\draw (-1.5,0) -- (1.5,0);%从点(-1.5,0)至(1.5,0)画一条直线, -- 表示直线
\draw (0,-1.5) -- (0,1.5);
\end{tikzpicture}.
\end{document}

这里的坐标是相对于一个特殊坐标系的, 1 代表了 1cm.

如果仅是一个 \draw 命令, 则也可以使用下面的 \tikz 命令,

\tikz \draw (-1.5,0) -- (1.5,0);%
% 等价于\r
\tikz{\draw (-1.5,0) -- (1.5,0)}%将{}中的内容作为参数
事实上, \tikz 将直到下一个分号之间内容或上面{}中的内容放入
\begin{tikzpicture}
\end{tikzpicture}
环境中.

Plain TeX

%% Plain TeX file
\input tikz.tex
\baselineskip=12pt
\hsize=6.3truein
\vsize=8.7truein
We are working on
\tikzpicture
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\endtikzpicture.
\bye

可以使用下面任一种方式生成 pdf 文件.

  • pdftex
  • tex-->dvips-->ps2pdf
  • tex-->dvipdfm

ConTeXt

%% ConTeXt file
\usemodule[tikz]
\starttext
We are working on
\starttikzpicture
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\stoptikzpicture.
\stoptext


References:
Till Tantau, The TikZ and PGF packages --- Manual for Version 2.00
http://sourceforge.net/projects/pgf


Search

New posted more ...