1 / 52

Introduction to Unix – CS 21

Introduction to Unix – CS 21. Lecture 17. Lecture Overview. More on LaTeX Inserting Figures xfig Creating your own commands Make Writing Makefiles Running make Revision Control Systems rcs CVS. Creating Figures In Unix. xfig

hafwen
Télécharger la présentation

Introduction to Unix – CS 21

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Unix – CS 21 Lecture 17

  2. Lecture Overview • More on LaTeX • Inserting Figures • xfig • Creating your own commands • Make • Writing Makefiles • Running make • Revision Control Systems • rcs • CVS

  3. Creating Figures In Unix • xfig • Simple drawing tool that allows you to make diagrams and pictures • Saves pictures to files called *.fig • Can export pictures to Encapsulated PostScript (*.eps)

  4. Example Of xfig

  5. Inserting Figures Into Latex Documents • Once you have a ps or eps file, you can insert them into your LaTeX documents • One way: \special{psfile=picture.eps} • Might have to mess with the vskip as this tends to place the bottom of the picture on the current line and not the top of the picture.

  6. Example Of Inserting A Figure

  7. Output Of Inserting A Figure

  8. Inserting With Space Adjustment

  9. Output Of Inserting A Figure With Space Adjustment

  10. Steps For Inserting A Figure Into LaTeX • 1. Make a figure using xfig (or some other tool that generates a .ps file) • 2. Use the \special{psfile=name.eps} command to place the picture in your document • 3. Use \vskip to position the picture correctly on the page

  11. Is There Another Way? • There are several other ways • LaTeX supports “floating” objects • Figures and diagrams that can slightly move about the page depending on the text • Can specify absolute locations of figures as well • Read more about it!

  12. LaTeX Commands Versus Environments • Command • Used to perform one singular task • \name{parameter} • Environment • Used to perform a task at the beginning and end of a block • \begin{name} • \end{name}

  13. Making A New Command • \newcommand{\name}[NUM]{COMMAND} • NUM can be 0-9 and represents the number of arguments passed to the command • Each parameter will be passed in a separate brace when called • Inside the command, {#1} will retrieve the value of the first parameter, {#2} will retrieve the second, and so on… • Example: • \newcommand{\assignment}[1]{\bf CS21 Assignment {#1}} • Usage: \assignment{2}

  14. Example Of A New Command

  15. Output Of Our New Command

  16. Making A New Environment • \newenvironment{\name}[NUM]{BEGIN COMMANDS}{END COMMANDS} • You must specify what happens when you begin an environment and what happens when you end and environment • Example: You might need a header and a signature for a letter, that would be the start and end of a “letter” environment

  17. Example Of A New Environment

  18. Output Of Our New Environment

  19. LaTeX Basics • That should be enough for you to get a good handle on how LaTeX works • There are a lot more commands and formatting techniques in LaTeX • If you can think of how your paper should be, you can probably get LaTeX to format it that way • Read more about it!

  20. Make • A generic tool for running and compiling programs • Usually used in conjunction with C programs • Not restricted to C files • Used to automate all of the steps in creating a final product • We will use make to automate the creation of .ps files from LaTeX files

  21. Makefiles • Make requires a special file named “Makefile” or “makefile” in your current directory • This is read in by make and contains a list of all commands that will be executed

  22. Must be a tab! Format Of A Makefile VARIABLE DECLARATIONS TARGET: DEPENDENCIES COMMANDS

  23. Variable Declarations In Makefiles • Typically all caps (but doesn’t have to be) • Example: MYDIR=/home/csgrads/villarre • Using variables is done just like bash shell • cat ${MYDIR}/myFile

  24. Targets In A Makefile • First target listed is special • Always the main target • You can specify a specific target on the command line • Example: make all • Make will execute all of the commands listed under the target in order to “make” the target

  25. Example Of A Makefile

  26. Dependencies • Before make can create a target, it checks and makes sure that any other target that the first target is dependant on is constructed • Make automatically keeps track of what files need to be reprocessed since the last time it was run

  27. Graphical Representation Of Dependencies targetOne: dependOne dependTwo echo “done” dependOne: echo “dependOne done” dependTwo: echo “dependTwo done”

  28. Example Of Dependencies

  29. Using make To Do Actual Work • Task: • Get a printable file from a LaTeX document we are working with • Steps: • Run latex on the .tex file • Run dvips on the .dvi file generated

  30. Example Makefile

  31. Example Run

  32. Implicit Rules And Variables In make • Make knows how to do some certain tasks automatically • Depends on a set of automatically declared variables • Example: Make knows that in order to get a .dvi file, it can run ${TEX} on a .tex file • Unfortunately, some of these variables are set to values you don’t want • Fortunately you can override the values of these variables

  33. Example Of Implicit Rules

  34. Fake Targets • Targets with no dependencies can be used to simply execute commands at will • Referred to as Phony targets (can be specified as such as well) • Common usage of Phony targets are to clean up directories

  35. Using make To Clean Up Directories • Latex creates a whole bunch of files we don’t need or may want to clean up • All we need is the .tex file and we can create everything else • .aux, .log, .dvi, .ps can all be removed • Create a special phony target called “clean” that executes the rm command

  36. Example Of make clean

  37. Make Basics • You now know how makefiles work and should be able to come up with a few working examples • Of course, make is much, much more complex than what I’ve shown here, but this is enough to be functional • Read more about it!

  38. Revision Control Systems • Have you ever been working on a program or paper and changed something substanital? • Have you ever wanted to go back to an older version that you threw away? • Revision control systems are designed to help you with just these sorts of issues

  39. Purpose Of Revision Control • Allows you to go back to previous versions • Maintain a history of changes • Locks out others from messing with the same file at the same time

  40. rcs – A Simple Revision Control Scheme • rcs is a system that will control access to a project and keep track of all changes and revisions • rcs • ci • co

  41. Setting Up The System For RCS • Create a subdirectory named RCS in the directory that contains the files you want to manage • Check in all of the files that you want to manage in order to get an initial revision • This removes the originals and creates a new file with the extension “,v” in the RCS directory

  42. Checking In • Usage: ci [FLAGS] file • Stands for check in • Keeps track of revision and version number • Starts at 1.1 (revision.version) and increments the version every time you check in • Flag: • -rNUM • Checks in the file with the given revision and version number

  43. Example Of Checking In

  44. Checking Out For Reading • Usage: co [FLAGS] file • Stands for check out • By default, checks out the most recently checked in version • Can’t check the file back in • Flag: • -rNUM • Check out revision and version NUM

  45. Example Of Checking Out For Reading

  46. Checking Out Locked • co –l file • Checks out a copy that can be modified and checked back in • Will prevent other users from checking out a version that they can modify • Only allows one person changing a file at a time

  47. Example

  48. Checking History Of A File - rlog • The rlog command will print out all of the log messages that you typed in when you checked in a modified file • Usage: rlog filename

  49. Other Access Restrictions - rcs • Usage: rcs [FLAGS] file • -aLOGIN • Add LOGIN to the list of users that can check out a file • -eLOGIN • Remove LOGIN from the list of users that can check out a file • Check out the man page for more information!

  50. CVS – Concurrent Versions System • A more advanced version of RCS • Works on hierarchical collections of directories • Trees and branches • Works over networks as well • Typical distribution format for Unix packages in development

More Related