Beamer uses the tikz macro package for drawing and animation instances

Source: Internet
Author: User
Tags commit

Previously, slides was written using beamer, and images were directly searched. Therefore, textures were used directly. I found the tikz macro package a few days ago and found it can be used to draw charts and combine it with beamer to form an animation effect. So I found some materials and tried to draw a simple flowchart.

First, you must specify the reference tikz macro package in the source file and define some simple graphics:

The code is as follows: Copy code

Usepackage {tikz}

Tikzstyle {block} = [rectangle, draw, fill = blue! 20, text width = 4em, text centered, rounded corners]
Tikzstyle {hugeBlock} = [rectangle, draw, fill = blue! 20,
Text width = 5em, text centered, rounded corners, minimum height = 4em]
Tikzstyle {line} = [draw,-latex ']



Two images are defined here. One is a common "block", which is filled in blue, the text is centered, and there is a rounded corner. The other is the same as the other, only the text width is different from the minimum width of the block.

 

Try to draw a simple static graph:

The code is as follows: Copy code
Begin {frame} {centralized workflow}
The workflow is similar to svn. The basic format is shown in the following figure:
Begin {tikzpicture} [node distance = 2 cm, auto]
Node [block] (center) {shared repository };
Node [block, below of = center, node distance = 3 cm] (centerDevelop) {developer 2 };
Node [block, left of = centerDevelop, node distance = 3 cm] (leftDevelop) {developer 1 };
Node [block, right of = centerDevelop, node distance = 3 cm] (rightDevelop) {developer 3 };
Path [line, <->] (center) -- (leftDevelop );
Path [line, <->] (center) -- (centerDevelop );
Path [line, <->] (center) -- node {push/pull} (rightDevelop );
End {tikzpicture}
End {frame}



The first step is to start a tikzpicture drawing area, and then draw nodes using node. All nodes use the previously defined "block ". You can use location parameters to control the relative location relationship between the drawn nodes and other nodes. After the node is drawn, draw the line of the node through the path command. The bidirectional arrow is used here, so the <-> symbol is added to the parameter. The method for connecting nodes is very simple. Just use the node name defined above and use-to connect them. This figure is based on the plug-in the centralized workflow introduction in pro git. The Source figure is: centralized workflow.

 

The figure is as follows:



Although it is not very nice, you can also modify the "block" graph to make it better.

Tikz is used in beamer. The most important thing is to make the generated pdf "animated", that is, to automatically generate multiple pdf pages, similar distribution effects are displayed during playback.

The code is as follows: Copy code
Begin {frame} frametitle {integration administrator workflow} framesubtitle {participant process}
Begin {tikzpicture} [node distance = 3 cm, auto]
Path [use as bounding box] (-1, 0) rectangle (10,-2 );
Path [line] <1-> node [block] (fock) {fock project };
Path [line] <2-> node [block, right of = fock, node distance = 3 cm] (clone) {clone to local}
(Fock) -- (clone );
Path [line] <3-> node [block, right of = clone, node distance = 3 cm] (edit) {modify}
(Clone) -- (edit );
Path [line] <4-> node [block, below of = edit, node distance = 3 cm] (commit) {Submit}
(Edit) -- (commit );
Path [line] <5-> node [block, left of = commit, node distance = 3 cm] (push) {push remote}
(Commit) -- (push );
Path [line] <6-> node [block, left of = push, node distance = 3 cm] (mergeRequst) {request merge}
(Push) -- (mergeRequst );
End {tikzpicture}
End {frame}



Here, we mainly rely on the path command. Its usage is the same as itemize/item in beamer. By specifying <n->, tex is drawn on the next n page. Note the first path. You must create a bounding box. Otherwise, nodes are automatically centered and rearranged during the layout, causing the absolute position of the subsequent page and the previous node to move. Each path generates a page, and this frame contains six pages.

 

Use the listings macro package in beamer

I tried to use the listings macro package in beamer for formatting and syntax highlighting several times, but the compilation failed. Finally, we have found the method. We need to add the [fragile] attribute After \ begin {frame}. If the frame contains a name, this attribute must be before the name, for example:

The code is as follows: Copy code

\ Begin {frame} [fragile] {title}
\ Begin {lstlisting}
Code
\ End {lstlisting}
\ End {frame}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.