Last active
August 29, 2015 13:57
-
-
Save ltiao/9464922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% Structured General Purpose Assignment | |
% LaTeX Template | |
% | |
% This template has been downloaded from: | |
% http://www.latextemplates.com | |
% | |
% Original author: | |
% Ted Pavlic (http://www.tedpavlic.com) | |
% | |
% Note: | |
% The \lipsum[#] commands throughout this template generate dummy text | |
% to fill the template out. These commands should all be removed when | |
% writing assignment content. | |
% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%---------------------------------------------------------------------------------------- | |
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS | |
%---------------------------------------------------------------------------------------- | |
\documentclass{article} | |
\usepackage{fancyhdr} % Required for custom headers | |
\usepackage{lastpage} % Required to determine the last page for the footer | |
\usepackage{extramarks} % Required for headers and footers | |
\usepackage{graphicx} % Required to insert images | |
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template | |
\usepackage{amsthm} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
% Margins | |
\topmargin=-0.45in | |
\evensidemargin=0in | |
\oddsidemargin=0in | |
\textwidth=6.5in | |
\textheight=9.0in | |
\headsep=0.25in | |
\linespread{1.1} % Line spacing | |
% Set up the header and footer | |
\pagestyle{fancy} | |
\lhead{\hmwkAuthorName \ (\hmwkStudentID)} % Top left header | |
%\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle} % Top center header | |
\chead{\hmwkClass: \hmwkTitle} % Top center header | |
\rhead{\firstxmark} % Top right header | |
\lfoot{\lastxmark} % Bottom left footer | |
\cfoot{} % Bottom center footer | |
\rfoot{Page\ \thepage\ of\ \pageref{LastPage}} % Bottom right footer | |
\renewcommand\headrulewidth{0.4pt} % Size of the header rule | |
\renewcommand\footrulewidth{0.4pt} % Size of the footer rule | |
\setlength\parindent{0pt} % Removes all indentation from paragraphs | |
\theoremstyle{plain} | |
\newtheorem{theorem}{Theorem}[section] | |
\newtheorem{lemma}[theorem]{Lemma} | |
\theoremstyle{definition} | |
\newtheorem{definition}{Definition} | |
\theoremstyle{remark} | |
\newtheorem*{note}{Note} | |
%---------------------------------------------------------------------------------------- | |
% DOCUMENT STRUCTURE COMMANDS | |
% Skip this unless you know what you're doing | |
%---------------------------------------------------------------------------------------- | |
% Header and footer for when a page split occurs within a problem environment | |
\newcommand{\enterProblemHeader}[1]{ | |
\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak | |
\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak | |
} | |
% Header and footer for when a page split occurs between problem environments | |
\newcommand{\exitProblemHeader}[1]{ | |
\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak | |
\nobreak\extramarks{#1}{}\nobreak | |
} | |
\setcounter{secnumdepth}{0} % Removes default section numbers | |
\newcounter{homeworkProblemCounter} % Creates a counter to keep track of the number of problems | |
\newcommand{\homeworkProblemName}{} | |
\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]{ % Makes a new environment called homeworkProblem which takes 1 argument (custom name) but the default is "Problem #" | |
\stepcounter{homeworkProblemCounter} % Increase counter for number of problems | |
\renewcommand{\homeworkProblemName}{#1} % Assign \homeworkProblemName the name of the problem | |
\section{\homeworkProblemName} % Make a section in the document with the custom problem count | |
\enterProblemHeader{\homeworkProblemName} % Header and footer within the environment | |
}{ | |
\exitProblemHeader{\homeworkProblemName} % Header and footer after the environment | |
} | |
\newcommand{\problemAnswer}[1]{ % Defines the problem answer command with the content as the only argument | |
\noindent\framebox[\columnwidth][c]{\begin{minipage}{0.98\columnwidth}#1\end{minipage}} % Makes the box around the problem answer and puts the content inside | |
} | |
\newcommand{\homeworkSectionName}{} | |
\newenvironment{homeworkSection}[1]{ % New environment for sections within homework problems, takes 1 argument - the name of the section | |
\renewcommand{\homeworkSectionName}{#1} % Assign \homeworkSectionName to the name of the section from the environment argument | |
\subsection{\homeworkSectionName} % Make a subsection with the custom name of the subsection | |
\enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]} % Header and footer within the environment | |
}{ | |
\enterProblemHeader{\homeworkProblemName} % Header and footer after the environment | |
} | |
%---------------------------------------------------------------------------------------- | |
% NAME AND CLASS SECTION | |
%---------------------------------------------------------------------------------------- | |
\newcommand{\hmwkTitle}{Homework\ 1} % Assignment title | |
\newcommand{\hmwkDueDate}{Thursday,\ March\ 13,\ 2014} % Due date | |
\newcommand{\hmwkClass}{COMP4141} % Course/class | |
\newcommand{\hmwkClassTime}{2:00pm} % Class/lecture time | |
\newcommand{\hmwkClassInstructor}{Ron van der Meyden} % Teacher/lecturer | |
\newcommand{\hmwkAuthorName}{Chi-Chun Louis Tiao} % Your name | |
\newcommand{\hmwkStudentID}{3390558} % Your Student ID | |
%---------------------------------------------------------------------------------------- | |
% TITLE PAGE | |
%---------------------------------------------------------------------------------------- | |
\title{ | |
\vspace{2in} | |
\textmd{\textbf{\hmwkClass:\ \hmwkTitle}}\\ | |
\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\ | |
\vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}} | |
\vspace{3in} | |
} | |
\author{\textbf{\hmwkAuthorName} \\ Student ID: \hmwkStudentID} | |
\date{} % Insert date here if you want it to appear below your name | |
%---------------------------------------------------------------------------------------- | |
\begin{document} | |
\maketitle | |
%---------------------------------------------------------------------------------------- | |
% TABLE OF CONTENTS | |
%---------------------------------------------------------------------------------------- | |
%\setcounter{tocdepth}{1} % Uncomment this line if you don't want subsections listed in the ToC | |
\newpage | |
\tableofcontents | |
\newpage | |
%---------------------------------------------------------------------------------------- | |
% PROBLEM 1 | |
%---------------------------------------------------------------------------------------- | |
% To have just one problem per page, simply put a \clearpage after each problem | |
\begin{homeworkProblem}[Exercise \arabic{homeworkProblemCounter}] | |
In the lectures it was mentioned that many functions are defined recursively | |
on the structure of strings. | |
%-------------------------------------------- | |
\begin{homeworkSection}{1)} % Section within problem | |
Give the recursive definition of a function $\mathtt{rev}: \Sigma^{*} \to \Sigma^{*}$, | |
which takes an arbitrary string as input and returns the reversed string. | |
For example, $\mathtt{rev}(string) = gnirts$ and $\mathtt{rev}(racecar) = racecar$. | |
\vspace{10pt} % Question | |
\problemAnswer{ % Answer | |
\begin{definition} | |
Here is my important proof | |
\end{definition} | |
} | |
\end{homeworkSection} | |
%-------------------------------------------- | |
\begin{homeworkSection}{2)} % Section within problem | |
Prove by induction that, for all $u \in \Sigma^{*}, |\mathtt{rev}(u)| = |u|$. | |
\vspace{10pt} % Question | |
\problemAnswer{ % Answer | |
\lipsum[6] | |
} | |
\end{homeworkSection} | |
%-------------------------------------------- | |
\end{homeworkProblem} | |
%---------------------------------------------------------------------------------------- | |
% PROBLEM 2 | |
%---------------------------------------------------------------------------------------- | |
\begin{homeworkProblem}[Exercise \#\arabic{homeworkProblemCounter}] % Custom section title | |
\lipsum[3] % Question | |
%-------------------------------------------- | |
\begin{homeworkSection}{(a)} % Section within problem | |
\lipsum[4]\vspace{10pt} % Question | |
\problemAnswer{ % Answer | |
\lipsum[5] | |
} | |
\end{homeworkSection} | |
%-------------------------------------------- | |
\begin{homeworkSection}{(b)} % Section within problem | |
\problemAnswer{ % Answer | |
\lipsum[6] | |
} | |
\end{homeworkSection} | |
%-------------------------------------------- | |
\end{homeworkProblem} | |
%---------------------------------------------------------------------------------------- | |
% PROBLEM 3 | |
%---------------------------------------------------------------------------------------- | |
\begin{homeworkProblem}[Prob. \Roman{homeworkProblemCounter}] % Roman numerals | |
%-------------------------------------------- | |
\begin{homeworkSection}{\homeworkProblemName:~(a)} % Using the problem name elsewhere | |
\problemAnswer{ % Answer | |
\lipsum[7] | |
} | |
\end{homeworkSection} | |
%-------------------------------------------- | |
\begin{homeworkSection}{\homeworkProblemName:~(b)} | |
\lipsum[8]\vspace{10pt} % Question | |
\problemAnswer{ % Answer | |
\lipsum[9] | |
} | |
\end{homeworkSection} | |
%-------------------------------------------- | |
\end{homeworkProblem} | |
%---------------------------------------------------------------------------------------- | |
% PROBLEM 4 | |
%---------------------------------------------------------------------------------------- | |
\begin{homeworkProblem}[Prob. \Roman{homeworkProblemCounter}] % Roman numerals | |
\problemAnswer{ % Answer | |
\lipsum[10] | |
} | |
\end{homeworkProblem} | |
%---------------------------------------------------------------------------------------- | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment