Title: Introduction to Unix CS 21
1Introduction to Unix CS 21
2Lecture Overview
- More on LaTeX
- Inserting Figures
- xfig
- Creating your own commands
- Make
- Writing Makefiles
- Running make
- Revision Control Systems
- rcs
- CVS
3Creating 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)
4Example Of xfig
5Inserting Figures Into Latex Documents
- Once you have a ps or eps file, you can insert
them into your LaTeX documents - One way \specialpsfilepicture.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.
6Example Of Inserting A Figure
7Output Of Inserting A Figure
8Inserting With Space Adjustment
9Output Of Inserting A Figure With Space Adjustment
10Steps For Inserting A Figure Into LaTeX
- 1. Make a figure using xfig (or some other tool
that generates a .ps file) - 2. Use the \specialpsfilename.eps command to
place the picture in your document - 3. Use \vskip to position the picture correctly
on the page
11Is 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!
12LaTeX Commands Versus Environments
- Command
- Used to perform one singular task
- \nameparameter
- Environment
- Used to perform a task at the beginning and end
of a block - \beginname
- \endname
13Making A New Command
- \newcommand\nameNUMCOMMAND
- 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\assignment1\bf CS21 Assignment
1 - Usage \assignment2
14Example Of A New Command
15Output Of Our New Command
16Making A New Environment
- \newenvironment\nameNUMBEGIN COMMANDSEND
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
17Example Of A New Environment
18Output Of Our New Environment
19LaTeX 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!
20Make
- 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
21Makefiles
- 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
22Format Of A Makefile
- VARIABLE DECLARATIONS
- TARGET DEPENDENCIES
- COMMANDS
23Variable Declarations In Makefiles
- Typically all caps (but doesnt have to be)
- Example MYDIR/home/csgrads/villarre
- Using variables is done just like bash shell
- cat MYDIR/myFile
24Targets 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
25Example Of A Makefile
26Dependencies
- 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
27Graphical Representation Of Dependencies
targetOne dependOne dependTwo echo
done dependOne echo dependOne
done dependTwo echo dependTwo done
28Example Of Dependencies
29Using 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
30Example Makefile
31Example Run
32Implicit 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 dont want - Fortunately you can override the values of these
variables
33Example Of Implicit Rules
34Fake 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
35Using make To Clean Up Directories
- Latex creates a whole bunch of files we dont
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
36Example Of make clean
37Make 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 Ive shown here, but this is enough to be
functional - Read more about it!
38Revision 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
39Purpose 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
40rcs 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
41Setting 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
42Checking 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
43Example Of Checking In
44Checking Out For Reading
- Usage co FLAGS file
- Stands for check out
- By default, checks out the most recently checked
in version - Cant check the file back in
- Flag
- -rNUM
- Check out revision and version NUM
45Example Of Checking Out For Reading
46Checking 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
47Example
48Checking 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
49Other 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!
50CVS 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
51In Lab Today
- Document construction with LaTeX
- Writing Makefiles to manage your LaTeX files
52Next Time
- Quiz 3
- Perl, LaTeX, make
- Setting up packages
- Configure scripts
- Apt, rpm
- Running jobs at prescribed times