520 likes | 609 Vues
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
E N D
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 • Simple drawing tool that allows you to make diagrams and pictures • Saves pictures to files called *.fig • Can export pictures to Encapsulated PostScript (*.eps)
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.
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
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!
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}
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}
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
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!
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
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
Must be a tab! Format Of A Makefile VARIABLE DECLARATIONS TARGET: DEPENDENCIES COMMANDS
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
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
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
Graphical Representation Of Dependencies targetOne: dependOne dependTwo echo “done” dependOne: echo “dependOne done” dependTwo: echo “dependTwo done”
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
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
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
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
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!
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
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
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
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
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
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
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
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
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!
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