LaTeX/C3/Feedback-diagram-with-Maths/English

From Script | Spoken-Tutorial
Revision as of 20:05, 27 November 2012 by Chandrika (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of script: Embedding Mathematics in Xfig

Author: Kannan Moudgalya

Keywords: Xfig, LaTeX, pdflatex, pdfcrop, briss


Resources for the tutorial

Visual Clue
Narration
Slide 1 Welcome to the spoken tutorial on embedding mathematics in Xfig
Slide 2 In this tutorial, I shall explain how to Create this Figure


Observe the mathematical expression in the second block


You can embed any mathematical expression after learning this tutorial

Slide 3 We shall create the figure in the previous slide, starting from this figure


which was created in the spoken tutorial on “Feedback Diagrams through Xfig”


You should learn this tutorial before starting the current one

Slide 4 Let me now explain what all you need to learn the material taught in this tutorial


I am using Xfig, Version 3.2, patch level 5


You also need LaTeX, and a familiarity with it


You also need image cropping software


pdfcrop works on Linux and Mac OS X


We will cover it in this tutorial


Briss is said to work on Windows also, but not covered in this tutorial

Slide 5 Let us go to Xfig
Open file Let us choose file, then open.


If we scroll through the list, we will see the file “feedback.fig”, created in the spoken tutorial on “Feedback Diagrams through Xfig”


Let us click it


We will see the figure inside this box


Let us open it. Let us bring it inside. Let us also zoom it.

Save file Using the “save as” option on “file”, we will save this figure as maths.


Let us save it.


We now have the file maths.fig

Edit Let us select “Edit” and click the text “Plant”


Let me take the mouse here. Let me delete this and enter

$G(z) = \frac z{z-1}$


Make sure that the mouse stays within the box while typing


The default value for “Flag” is “normal” - change it to “special”


Click “done”

As the text is long, it overlaps with other entries


Let us move the text outside the box and work with it.


Let me click here.


Let me choose grid mode.


Once we are satisfied with any changes that we may want here, we can put it back inside the box.

Let us save the file.


Let us export using combined pdf and latex files.


File. Export. Combined pdf and LaTeX. Let us export.


There is an error message I get.


But let us not worry about this.


Let me go to the terminal.

Terminal Let me type “ls -lrt”


We get a list of files, with the last one being the most recent


The last two files are maths.pdf_t and maths.pdf

Open maths.pdf

on terminal

Let us give the command “open maths.pdf”


Let us bring it inside.


We can see the block diagram without the mathematical expression


Let me close this

C-X, C-f in emacs

type maths.pdf_t

Let us see maths.pdf_t in emacs editor that I have already opened


It is here. Let me open it.

Please note that you do NOT have to use emacs


You can use WHATEVER editor that you are comfortable with

Highlight includegraphics

highlight color

You can see see that the “picture” environment is used


It also makes use of “includegraphics” and “color” packages – we need to tell LaTeX to take care of this requirement

C-X, C-f in emacs

type maths-bp.tex

Let me now open the file maths-bp.tex, I have already created for this tutorial


I have used article class


I have used color and graphicx packages as these are used in the file pdf_t, the one we saw earlier.


I want empty pagestyle, as I do not want the page number


Finally, I want to include the file maths.pdf_t

pdflatex maths-bp


open maths-bp.pdf

Let us invoke the command “pdflatex maths-bp” in the terminal


We get the message that the maths-bp.pdf is created.


Let us open it with the command “open maths-bp.pdf”


We have the file we want. Let me zoom it.

Move text


pdflatex maths-bp


click maths-bp.pdf

Now that we know that the mathematical expression is working, let us move the text inside the block


Let us save and export. It is already in the required language.

Export.


Let us dismiss this warning.


Let me compile it again.


Let us click the pdf browser that has the file


Now you see the mathematical expression inside the box, the way we want

Let us now see what happens if we do not choose the special flag.


Let me come here.

Xfig Let me edit the text, change the “Special Flag” to “normal”. Done.


File, save. Let me export

terminal Let me compile. Let me come here.


The formula is no longer in the form we want

Xfig Let us change the “special flag” back to “special”


Save, export

Terminal Recompile. See that the file is in the form we want.



Let us now improve the appearance of this formula
Xfig In this case, the use of dfrac will make the fraction look better.


In view of this, let us change frac to dfrac.


Let me click here. Keep the mouse inside the box.


Put d here. Done. Save, export.

Terminal Let us compile once again using “pdflatex”


We get the error message “Undefined control sequence” \dfrac


LaTeX complains because the command \dfrac is defined in the package “Amsmath” but we have not included it.


We need to include it in the file maths-bp.tex.


Let us do it. Let us go to emacs.

Emacs Enter “\usepackage{amsmath}”


Let us save the file. Let us compile once again. Let me first exit.

Terminal Let me now recompile. Now it compiles.
Let us click this.


We see that the fraction has now come out nicely.


We have now achieved our objective of learning how to embed mathematical expressions in Xfig

It is important to note that Xfig does not interpret the LaTeX commands at all.


The interpretation is done by the “pdflatex” command


The LaTeX commands have to be correct and consistent at the time of compilation.

We will now explain how to remove the white space around the figure.


Let me go to the terminal.

Pdfcrop Let me type the command “pdfcrop maths-bp.pdf” - this is the file we created, into “maths-out.pdf”.


Pdfcrop says one page written on this file.


“pdfcrop” takes an input file, trims the space around the figure and writes out the cropped file in the output file.


“pdfcrop” is already installed in my system.


If you do not have it, you need to install it first.


Let us view this output file by the command, “open maths-out.pdf”.


Let me bring it inside.


The figure has now become extremely compact.


The white space that was here has been completely removed.


We can now insert this into documents.


Let me close this. Let me close this also.


Let me come back to the slides.

The software “briss” can also be used to crop the white space.


It is supposed to work on Linux, Mac OS X and also on Windows.


I have checked its working on Mac OS X.


But we will not demonstrate it here.

We have now come to the end of this tutorial
Slide 6 We have an assignment for you
Make the diagram created in this tutorial more symmetric and beautiful


Try out different mathematical expressions


Try out other options, such as flip and rotate, not covered in the spoken tutorial


Try to build different diagrams


Explore the library


Do an internet search and locate information relevant to Xfig

Slide 7 Useful learning material is available at spoken-tutorial.org. It is here.


The concept of spoken tutorials is explained in "What is a Spoken Tutorial"


You may learn LaTeX using the spoken tutorials available here, which I have downloaded in this tab.


The tutorial on Mathematical Typesetting explains how to create maths in LaTeX


The tutorial on Tables and Figures explains how to place figures, of the type created in this tutorial, into documents


This website has a lot of useful information, including, Xfig tutorials. Come back to the slides.

Slide 8 Spoken Tutorial is a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT (NMEICT), MHRD, Government of India.


More information on this mission is available at

spoken-tutorial.org/NMEICT-Intro

Slide 9 We welcome your participation and also feedback.


This is Kannan Moudgalya signing off. Thanks for joining. Goodbye.

Contributors and Content Editors

Chandrika, Nancyvarkey, PoojaMoolya