The following is information, tutorials, and help links for tools that we will use in for remote course activites and course work. More course-specific information is available off the CS 41 webpage, and from individual assignment pages.
Remote Access and Code Envirnoment Tools:
ssh and scp
ssh is useful for remotely logging into the CS lab machines. scp is useful for copying files between your local system and the CS system.
ssh
You can remotely connect to any machine by sshing in as you to lab.cs.swarthmore.edu
or to a particular machine by logging in as you
to a specific machinename.cs.swarthmore.edu
. For example:
# log into some lab machine:
ssh yourusername@lab.cs.swarthmore.edu
# log into owl:
ssh yourusername@owl.cs.swarthmore.edu
You can find the names of lab machines here: cs lab machines
scp
scp is like the cp command, but for copying files between two different machines.
# copy a file named "bio.txt" from the "cs41/labs/lab01" directory on a lab machine to your machine scp yourusername@cs.swarthmore.edu:cs41/labs/lab01/bio.txt . # copy a file named "bio2.txt" from current directory on your machine onto a lab machine # Note: by default, this will place the file in your home directory; i.e., "/home/yourusername" scp bio2.txt yourusername@cs.swarthmore.edu: # copy a file named "bio3.txt" from current directory on your machine onto a lab machine in the "cs41/labs/lab01" directory scp bio3.txt yourusername@cs.swarthmore.edu:cs41/labs/lab01
ssh and scp links
Tools for lab work
Piazza and GitHub
As in most CS courses, we will use piazza for Q&A and github for lab assignments. Here is some more information about both, and links to piazza and git hub for CS 41:
piazza resources
Git and the college’s Enterprise GitHub are used for lab work.
git resources
-
using git for CS labs contains some basic (and verbose) git instructions for using git for CS course lab work. It is written using cs31 as an example, but replace with your own course number.
-
git on our system and git help. This is a more complete reference for using git on our system.
LaTeX
LaTeX is the standard tool for scientific writing and typesetting. Here is a sample LaTex file. LaTeX is a markup language, which means that you provide text along with commands to typeset or markup that text. You then need to compile a LaTeX document.
Compiling LaTeX
The easiest and most direct way to compile is via pdflatex. Here’s an example:
pdflatex LearningLaTeX.tex
This will either produce a pdf document you can read with a standard pdf reader such as Acroread, or will print out error(s) encountered during the LaTeX compilation process.
Working with LaTeX remotely.
If you are working with LaTeX remotely, you might not have LaTeX installed on your local machine. In this case, you have a couple of options:
-
Edit/Compile your LaTeX file on lab machines. To this, you’ll need to ssh into a lab machine, and edit/compile your LaTeX file from there. Then, you can use scp to copy your compiled pdf to a local machine to read it.
-
Use an online LaTeX editor such as Overleaf. In past years, several students have used overleaf to write their LaTeX. It is convenient for writing partered assignments. Warning: Overleaf tends to ignore compilation errors and give you the best pdf it can render. Before submitting a LaTeX file, make sure you can compile it using pdflatex and it looks the way you’d like.
-
Install pdflatex on your home machine.
The basic structure of a LaTeX file
It is likely that you will modify an existing LaTeX template file (e.g. this template) rather than starting from scratch. However, if you do start from scratch, the following snippet of LaTeX illustrates the minimal code needed to get started.
\documentclass{article}
\usepackage{amsmath} % Math notation from the American Mathematical Society.
\usepackage{amssymb} % Typographical symbols from the same.
\begin{document}
Hello!
\end{document}
Brief explanations of each line lie below:
-
The line
\documentclass{article}
tells LaTeX you want to write an "article" document. LaTeX documents start with this line. -
The next few lines add LaTeX packages, which are similar in spirit to
#include
lines in C++ orimport
in Python. -
\begin{document}
and\end{document}
specify where the content of your document starts and stops.
Formatting
LaTeX has several formatting commands that make your file look nicer. A few are listed below:
-
\textit{this is italicized.}
renders 'this text' in italic. Here is what gets produced \(\textit{this is italicized.}\) -
\textbf{this is boldface.}
gets rendered as \(\textbf{this is boldface.}\)
LaTeX has environments for bullet lists and numbered lists.
-
The itemize environment gives unordered bullet-lists.
Here is an unordered list.
\begin{itemize}
\item Your first item is here.
\item This is your second item.
\item This is the third item.
\end{itemize}
Here is the compiled LaTeX.
Here is an ordered list.
\begin{enumerate}
\item Item One.
\item Item Two.
\item Item Three.
\end{enumerate}
Here is the compiled LaTeX.
Math
One of the real strengths of LaTeX is its ability to easily typeset mathematical notation. To render mathematics in LaTeX, enclose the math in dollar signs e.g.
The quadratic equation is $ax^2 + bx + c = 0.$
Which gets rendered as: \(\text{The quadratic equation is }ax^2 + bx +c.\)
Sometimes, it’s nicer to put the math on its own line, cenetered in the page. Do this using double dollar signs:
The quadratic equation lies below: $$ax^2 + bx + c=0\ .$$
Here is the compiled LaTeX.
The align* Environment
If your LaTeX math runs across multiple lines of text, LaTeX provides an elegant way of typesetting this nicely called the align\* environment. Here is some sample LaTeX code:
\begin{align*}
(n+1)(n-1) &= n^2 + n - n -1 \\
&= n^2-1
\end{align*}
which gets rendered as:
\(\begin{align*} (n+1)(n-1) &= n^2 + n - n -1 \\ &= n^2-1\end{align*}\)
Make sure to put a double backslash '\\' to denote the end of each line of your math equations. (no double-backslash is needed after the last line). The ampersand '&' is a control character that specifies vertical alignment. When this LaTeX is compiled, it will line up each line where the ampersands are. In this example, the equal sign in the second line of math will line up immediately below the equal sign in the first line.
Subscripts and Superscripts
In math mode, it is common to use subscripts and superscripts. You can do this in LaTeX using '_' and '^'. For example:
$a_0 = x^2 + 4$
gets rendered as \(a_0 = x^2 + 4\)
Summations
If you want to write summations, use the \sum
command. For example,
$\sum_{i=1}^n i = \frac{n(n+1)}{2}.$
is rendered as \(\sum_{i=1}^n i = \frac{n(n+1)}{2}.\)
Including Images
To include an image, use the graphicsx
package and the
\includegraphics
command.
...
\usepackage{graphicsx}
...
\includegraphics{bunny.jpg}
...