Skip to main content

Latex Tutorial: How to use Tikz to create images in Latex

Tikz is one of the most widely used packages for image creation in Latex. It has so much that there is absolutely nothing that you can't draw with latex and can with some other tool. In this tutorial we explain the basics of Tikz. We go over the basic shapes, how to draw them, how to understand the co-ordinates, and positioning of the components of an image. 

Specifically, this tutorial demonstrates:
  1. How to draw a rectangle in Latex using TikZ
  2. How to draw a ellipse in Latex using TikZ
  3. How to draw a circle in Latex using TikZ
  4. How to draw an arc in Latex using TikZ
  5. How to fill the shapes with colors
  6. How to change the line styles - solid, dashed etc.

The code for this experiment is here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, shadows}
\begin{document}
\begin{tikzpicture}
\draw[fill=blue] (2,3) ellipse (2 and 3);
\draw[fill=red, style=dashed] (2,3) circle (2);
\draw (0,0) rectangle (4,4);
\draw[fill=red!50] (1,2) -- +(40:4) arc(40:180:4) -- cycle;
\end{tikzpicture}
\end{document}
The video where I develop this code and explain everything is below. If you have a question or want me to demonstrate any particular feature in Latex just leave me a comment and I will address it.



Comments

  1. Hello...Thanx For Sharing Those Videos...It Really Helped Me Until I Started Using Tikz...I Copy Pasted Ur Code And Tried To Run It But My Latex Gave Me :
    texify.exe: Permission denied: flow chart.log
    texify.exe: Data: flow chart.log

    Whats The Problem?
    I'd Appreciate It If You Could Help Me :)

    ReplyDelete
    Replies
    1. Hi,

      Can you close all the files and Miktex and start from scratch again with a basic code? You might have permission issues due to some file conflict.

      If that does not help, try restarting especially if you use a windows machine. This code just works fine for me. I haven't run into that problem so don't know much but I will try to help.

      Regards,
      Dinesh Agarwal

      Delete

Post a Comment

Comments on QuickLatex are strictly moderated. As much as I hate moderation, I must fight spam. Please rest assured that if your comment is relevant I will approve it and answer.

Popular posts from this blog

Latex Tutorial: How to Create Images, Diagrams, and Flow Charts Using Latex

This tutorial is an extension of previous video tutorial on how to use tikz for image creation in Latex . In this video I explain how to set up your document for flow chat design. This equally applies to any other image that uses similar structure. Specifically, in this video I talk about following things: How to create a flow chart How to setup styles for reusable components of an image How to draw arrows from one component to other How to change the styles of components How to change the arrowhead for Latex arrows How to align components left, right, top, and below of each other The code use:d in the video is here: \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes,shadows,arrows} \begin{document} \tikzstyle{decision} = [diamond, draw, fill=blue!50] \tikzstyle{line} = [draw, -stealth, thick] \tikzstyle{elli}=[draw, ellipse, fill=red!50,minimum height=8mm, text width=5em, text centered] \tikzstyle{block} = [draw, rectangle, fill=blue!50, text width...

LaTeX Video Tutorial: How to Create a Resume or CV (Curriculum Vitae) using LaTeX

One of the most frequent questions my colleagues ask me is how to create a Resume or Curriculum Vitae (CV), if you will, in LaTeX . I have a style file that was passed to me by a friend who found it on Internet. Since this looked good I used it and, thanks to the original contributor, I am going to share it with you all today. You will be able to download these files and create a professional Resume for yourself.  The files can be download from the linked locations: The Resume.tex file (main document) The Class file res.cls (for page setting) In the video tutorial , attached below, I have explained how to change the text for your needs. The structure of the Resume (or CV) is highly flexible and once you get hold of the basics it will be pretty straight forward for you to tweak it for your own use.  I have tried to add the basic sections that are present in most of the Resumes but you will most probably add more depending on your requirements. I am prett...

How to draw Reddit Alien in LaTeX using Tikz - Video tutorial and code

If you are not a Redditor you are a lucky person. It's a one way traffic scenario with no dead end. Once you subscribe to Reddit there is no way back and it is no good being there. I am expecting my colleagues to have an intervention for my Reddit addiction soon but till then I am all here to invest (read:waste) my precious time. Since we got that out of our way, let us get back to business. Today, we are going to see how to draw a cartoon figure using LaTeX. The motivation behind this post is /r/latex on Reddit as I wanted that subreddit to have its logo drawn in LaTeX. I did not know it already was in LaTeX but it seems my work is appreciated there so I am going to contribute my 2 cents to the community. Specifically, we will learn following things in this tutorial: How to work with Colors - defining RGB colors in LaTeX. How to use multiple layers to set order of document objects (send to back, bring forward like functionality). How to use Arcs in an effective way....