\documentclass{article} % Change "article" to "report" to get rid of page number on title page \usepackage{amsmath,amsfonts,amsthm,amssymb} \usepackage{setspace} \usepackage{fancyhdr} \usepackage{lastpage} \usepackage{extramarks} \usepackage{chngpage} \usepackage{soul} \usepackage[usenames,dvipsnames]{color} \usepackage{graphicx,float,wrapfig} \usepackage{ifthen} \usepackage{listings} \usepackage{courier} % Homework Specific Information \newcommand{\hmwkTitle}{Homework Example} \newcommand{\hmwkSubTitle}{} % No subtitle, so this will be excluded \newcommand{\hmwkDueDate}{\today} \newcommand{\hmwkClass}{ECE 759} \newcommand{\hmwkClassTime}{2:30} \newcommand{\hmwkClassInstructor}{Falkner} \newcommand{\hmwkAuthorName}{Graduate Student} % In case you need to adjust margins: \topmargin=-0.45in % \evensidemargin=0in % \oddsidemargin=0in % \textwidth=6.5in % \textheight=9.0in % \headsep=0.25in % % This is the color used for MATLAB comments below \definecolor{MyDarkGreen}{rgb}{0.0,0.4,0.0} % For faster processing, load Matlab syntax for listings \lstloadlanguages{Matlab}% \lstset{language=Matlab, % Use MATLAB frame=single, % Single frame around code basicstyle=\small\ttfamily, % Use small true type font keywordstyle=[1]\color{Blue}\bf, % MATLAB functions bold and blue keywordstyle=[2]\color{Purple}, % MATLAB function arguments purple keywordstyle=[3]\color{Blue}\underbar, % User functions underlined and blue identifierstyle=, % Nothing special about identifiers % Comments small dark green courier commentstyle=\usefont{T1}{pcr}{m}{sl}\color{MyDarkGreen}\small, stringstyle=\color{Purple}, % Strings are purple showstringspaces=false, % Don't put marks in string spaces tabsize=5, % 5 spaces per tab % %%% Put standard MATLAB functions not included in the default %%% language here morekeywords={xlim,ylim,var,alpha,factorial,poissrnd,normpdf,normcdf}, % %%% Put MATLAB function parameters here morekeywords=[2]{on, off, interp}, % %%% Put user defined functions here morekeywords=[3]{FindESS, homework_example}, % morecomment=[l][\color{Blue}]{...}, % Line continuation (...) like blue comment numbers=left, % Line numbers on left firstnumber=1, % Line numbers start with line 1 numberstyle=\tiny\color{Blue}, % Line numbers are blue stepnumber=5 % Line numbers go in steps of 5 } % Setup the header and footer \pagestyle{fancy} % \lhead{\hmwkAuthorName} % \chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle} % \rhead{\firstxmark} % \lfoot{\lastxmark} % \cfoot{} % \rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}} % \renewcommand\headrulewidth{0.4pt} % \renewcommand\footrulewidth{0.4pt} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Make title \title{\vspace{2in}\textmd{\textbf{\hmwkClass:\ \hmwkTitle\ifthenelse{\equal{\hmwkSubTitle}{}}{}{\\\hmwkSubTitle}}}\\\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\\vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}}\vspace{3in}} \date{} \author{\textbf{\hmwkAuthorName}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This is used to trace down (pin point) problems % in latexing a document: %\tracingall %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Some tools % Use these to play with the headers and footers \newcommand{\enterProblemHeader}[1]{\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak% \nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak}% \newcommand{\exitProblemHeader}[1]{\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak% \nobreak\extramarks{#1}{}\nobreak}% \newcommand{\homeworkProblem}[3] {\enterProblemHeader{#1} \subsection*{#1\ifthenelse{\equal{#2}{}}{}{ (#2)}}% #3 \exitProblemHeader{#1}} %%% I think \captionwidth (commented out below) can go away %%% %% Edits the caption width %\newcommand{\captionwidth}[1]{% % \dimen0=\columnwidth \advance\dimen0 by-#1\relax % \divide\dimen0 by2 % \advance\leftskip by\dimen0 % \advance\rightskip by\dimen0 %} % Includes a figure % The first parameter is the label, which is also the name of the figure % with or without the extension (e.g., .eps, .fig, .png, .gif, etc.) % IF NO EXTENSION IS GIVEN, LaTeX will look for the most appropriate one. % This means that if a DVI (or PS) is being produced, it will look for % an eps. If a PDF is being produced, it will look for nearly anything % else (gif, jpg, png, et cetera). Because of this, when I generate figures % I typically generate an eps and a png to allow me the most flexibility % when rendering my document. % The second parameter is the width of the figure normalized to column width % (e.g. 0.5 for half a column, 0.75 for 75% of the column) % The third parameter is the caption. \newcommand{\scalefig}[3]{ \begin{figure}[ht!] % Requires \usepackage{graphicx} \centering \includegraphics[width=#2\columnwidth]{#1} %%% I think \captionwidth (see above) can go away as long as %%% \centering is above %\captionwidth{#2\columnwidth}% \caption{#3} \label{#1} \end{figure}} % Includes a MATLAB script. % The first parameter is the label, which also is the name of the script % without the .m. % The second parameter is the optional caption. \newcommand{\matlabscript}[2] {\begin{itemize}\item[]\lstinputlisting[caption=#2,label=#1]{#1.m}\end{itemize}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% The main document content %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{spacing}{1.1} \maketitle \newpage % Here we see title and subtitle for each homework problem. The title is short % so it can be included in the header/footer. The subtitle is long and will only % be written once. % % Notice that this is a MACRO and *NOT* an environment, so there is a closing % brace that needs to be included. See below. \homeworkProblem{Problem 1}{Example of a Homework Problem Solution}% { % Start homework solution The listing below shows a MATLAB script that was used to generate Figure~\ref{homework_example_fig}. % Notice that this \matlabscript has no caption % That also means that this script has no label, so we can't refer to it. % Otherwise it would be labeled the first parameter, "homework_example". \matlabscript{homework_example}{} \scalefig{homework_example_fig}{0.5}{Figure Generated By Listing~\ref{homework_example}} } % End homework solution \end{spacing} \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%