Advertisement
cmhughes

mainfile.tex

Nov 12th, 2011
930
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 22.86 KB | None | 0 0
  1. \documentclass[10pt,twoside]{report}
  2. \usepackage{etex}
  3. \reserveinserts{28}
  4. \usepackage[left=6cm,right=1cm,showframe=false,                 % page settings (showframe is useful!)
  5.     textheight=27cm,
  6.     top=1.5cm,bottom=1.5cm,asymmetric=true,bindingoffset=1cm]{geometry}              
  7. \usepackage{amsmath}                            % mathematical content
  8. \usepackage{amssymb}                            % mathematical content
  9. \usepackage[amsmath,standard,framed,thmmarks]{ntheorem} % custom enumerations *Needs to stay here, otherwise cross references can go wrong*
  10. \usepackage{ifthen}                             % conditionals
  11. \usepackage{xcolor}                             % colour
  12. \usepackage{answers}                            % solutions to problems done *beautifully*
  13. %\usepackage[nosolutionfiles]{answers}
  14. \usepackage{framed}                             % needed for putting boxes round theorems, examples
  15. \usepackage[explicit]{titlesec}
  16. \usepackage{multicol}                           % multicols
  17. \usepackage{changepage}                         % needed for hanging paragraphs
  18. \usepackage{calc}                               % calculations (such as \textwidth/2)
  19. \usepackage{fancyhdr}                           % headers & footers
  20. \usepackage[small,bf]{caption}                  % figures/tables in margins, and not floating
  21. \usepackage{subcaption}                         % subfigures, subtables (replaces subfig)
  22. \usepackage{xstring}                            % needed to determine if problems are odd or even
  23. \usepackage{enumitem}                           % enumerate & itemize
  24. \usepackage{placeins}                           % FloatBarrier
  25. \usepackage{minitoc}                            % mini-table of contents
  26. \usepackage{marginfix}                          % fixes margin notes (otherwise they can cut through pages)
  27. \usepackage{needspace}                          % needed to keep problems looking good (stops ugly pagebreaks)
  28. \usepackage{xargs}                              % helps with optional arguments for environments
  29. \usepackage{booktabs}       % used with tables (allows \toprulewidth etc)
  30. \usepackage{flafter}          % ensures that floats don't appear until after their placement in the text
  31. % pstricks
  32. \usepackage[pdf]{pstricks}
  33. \usepackage{pstricks-add}
  34. % load the hyperref last
  35. \usepackage{hyperref}           % to allow hyper refs in the final pdf document
  36.  
  37.                                 % hyperref NEEDS TO STAY AT THE END!
  38. \usepackage[all]{hypcap}        % needed to help hyperlinks direct correctly;
  39.                                 % note that this needs to be loaded AFTER
  40.                                 % the hyperref package; the option [all]
  41.                                 % makes hyperlinks to figures & tables go
  42.                                 % to the top
  43. \usepackage{cleveref}       % needs to be loaded after hyperref
  44.  
  45. % hyperref settings- it seemed to work better here rather than
  46. % as options to the \usepackage call above
  47. \hypersetup{colorlinks=true,
  48. linkcolor=blue%,breaklinks=true
  49. }
  50.  
  51. \psset{algebraic=true}           % set up options for PS figures
  52.  
  53. % custom ps options
  54. \newpsobject{pccpsplot}{psplot}{linecolor=blue,plotstyle=curve,%
  55.                                 linewidth=1pt,arrows=<->}
  56. \newpsobject{pccgridline}{psline}{linecolor=black!20,linestyle=dashed}
  57. \newpsobject{pccpsframe}{psframe}{linecolor=gray,linewidth=0pt}
  58. \newpsobject{pccpsSolDot}{psdots}{linecolor=blue,dotsize=0.25}
  59. \newpsobject{pccpsHolDot}{psdots}{linecolor=blue,dotsize=0.25,dotstyle=o}
  60. \newpsobject{pccasymptote}{psline}{linestyle=dotted,linecolor=red}
  61.  
  62. % grid stuff
  63. \newcommand{\drawXgrid}[3]{%
  64.                        \multido{\nx=#1+#2}{#3}%
  65.                        {%
  66.                         \pccgridline(\nx,\ymin)(\nx,\ymax)
  67.                        }%
  68. }
  69. \newcommand{\drawYgrid}[3]{%
  70.                        \multido{\ny=#1+#2}{#3}%
  71.                        {%
  72.                         \pccgridline(\xmin,\ny)(\xmax,\ny)
  73.                        }%
  74. }
  75.  
  76.  
  77. % set figure width
  78.  
  79. \newlength{\figurewidth}
  80. % setwindow command: takes 6 arguments (1st is optional)
  81. %       [1]. aspect ratio (height = aspect ratio * width) default=1
  82. %         2. xmin (number)
  83. %         3. ymin (number)
  84. %         4. xmax (number)
  85. %         5. ymax (number)
  86. %         6. figurewidth (length)
  87. \makeatletter
  88. \newcommand{\setwindow}[6][1]{\def\xmin{#2}%
  89.                            \def\ymin{#3}%
  90.                            \def\xmax{#4}%
  91.                            \def\ymax{#5}%
  92.                            % set up xunit
  93.                            \pstFPsub\viewingwidth{#4}{#2}%
  94.                            \pstFPdiv\result{\strip@pt#6}{\viewingwidth}%
  95.                            \psset{xunit=\result pt}
  96.                            % set up yunit
  97.                            \pstFPsub\viewingheight{#5}{#3}%
  98.                            \pstFPdiv\result{\strip@pt#6}{\viewingheight}%
  99.                            % set up aspect ratio
  100.                            \pstFPmul\result{\result}{#1}%
  101.                            \psset{yunit=\result pt}%
  102.                            }
  103. \makeatother
  104.  
  105. % caption settings
  106. \captionsetup[table]{skip=0pt}
  107. \captionsetup[subfigure]{labelformat=parens,labelsep=colon,labelfont=normal}
  108. \captionsetup[subtable]{labelformat=parens,labelsep=colon,labelfont=normal}
  109.  
  110. % enumerate settings
  111. \setlist{itemsep=0.05em,topsep=0.01em}
  112.  
  113. % paragraph settings
  114. \setlength{\parskip}{3.0mm}
  115. \setlength{\parindent}{0.0mm}
  116.  
  117. % use left margin
  118. \reversemarginpar
  119. \setlength{\marginparwidth}{5cm}
  120.  
  121. % Define fix command
  122. %   - it puts a comment in the margin
  123. %   - it writes to a file with a list of things that need fixing
  124. \newcommand{\fixthis}[1]%
  125. {%
  126.  \marginpar{\huge \color{red} \framebox{FIX}}%
  127. \typeout{FIXTHIS: p\thepage : #1^^J}%
  128. }
  129.  
  130. %   BEGIN CLEVEREF
  131.  
  132. % standard environments
  133. \crefname{table}{Table}{Tables}
  134. \Crefname{table}{Table}{Tables}
  135. \crefname{figure}{Figure}{Figures}
  136. \Crefname{figure}{Figure}{Figures}
  137. \crefname{section}{Section}{Sections}
  138. \Crefname{section}{Section}{Sections}
  139. \crefname{equation}{Equation}{Equations}
  140. \Crefname{equation}{Equation}{Equations}
  141. % custom environments
  142. \crefname{problem}{Problem}{Problems}
  143. \Crefname{problem}{Problem}{Problems}
  144. \crefname{pccdefinition}{Definition}{Definitions}
  145. \Crefname{pccdefinition}{Definition}{Definitions}
  146. \crefname{pccexample}{Example}{Examples}
  147. \Crefname{pccexample}{Example}{Examples}
  148. \crefname{enumi}{Problem}{Problems}
  149. \Crefname{enumi}{Problem}{Problems}
  150. % conjunction between range; e.g Figures 1.2-1.3
  151. \newcommand{\crefrangeconjunction}{|}
  152.  
  153. %   BEGIN MARGIN ENVIRONMENTS (shamelessly copied from tufte documentclass)
  154. \makeatletter
  155. % Margin float environment
  156. \newsavebox{\@tufte@margin@floatbox}
  157. \newenvironment{@tufte@margin@float}[2][-1.2ex]%
  158.   {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
  159.   \begin{lrbox}{\@tufte@margin@floatbox}%
  160.   \begin{minipage}{\marginparwidth}%
  161.     \def\@captype{#2}%
  162.     \hbox{}\vspace*{#1}%
  163.     \noindent%
  164.   }
  165.   {\end{minipage}%
  166.   \end{lrbox}%
  167.   \marginpar{\usebox{\@tufte@margin@floatbox}}%
  168.   }
  169.    
  170. % Margin figure environment
  171. \newenvironment{marginfigure}[1][-1.2ex]%
  172.   {\begin{@tufte@margin@float}[#1]{figure}%
  173.    \capstart\endgraf}% <-- Hyperlink jumps to start of 'marginfigure'
  174.   {\end{@tufte@margin@float}}
  175.    
  176. % Margin table environment
  177. \newenvironment{margintable}[1][-1.2ex]%
  178.   {\begin{@tufte@margin@float}[#1]{table}%
  179.    \capstart\endgraf}% <-- Hyperlink jumps to start of 'margintable'
  180.   {\end{@tufte@margin@float}}
  181.    
  182. \makeatother
  183. %   END MARGIN ENVIRONMENTS
  184.  
  185. %   BEGIN SOLUTIONS TO PROBLEMS
  186. % open the answer files (short, long, and hints)
  187. \Opensolutionfile{shortsolutions}
  188. \Newassociation{shortsolution}{shortSoln}{shortsolutions}
  189.  
  190. % put titles in the solution files
  191. \begin{Filesave}{shortsolutions}
  192. % SHORT SOLUTIONS FILE
  193. % Begin by (re-)setting the chapter counter to 0
  194. % which is used for hyperlinks from solutions to questions
  195. %
  196. % This allows us to put Problem 1, 2, 3, etc in every chapter
  197. % as the hyperlinks have the form \hypertarget{soln:#1\thechapter}{}
  198. \section*{Answers}
  199. \setcounter{chapter}{0}
  200.  
  201. \end{Filesave}
  202. %   END SOLUTIONS TO PROBLEMS
  203.  
  204. %   BEGIN CUSTOM THEOREMS (for problems, subproblems)
  205. % set up showoddsolns and showEVEN
  206. \newboolean{showoddsolns}
  207. \setboolean{showoddsolns}{true}
  208. \newboolean{showevensolns}
  209. \setboolean{showevensolns}{true}
  210.  
  211. % this boolean is used in the problem and subproblem definition
  212. \newboolean{showSolution}
  213. \setboolean{showSolution}{true}
  214.  
  215. % PROBLEM environment
  216. % \begin{problem}[1][2]
  217. %   ...
  218. % \end{problem}
  219. %
  220. %  [1]: description of the problem
  221. %  [2]: special
  222. %
  223. % Both arguments are optional; the second argument
  224. % can be left off, empty, or special. If it is non-empty
  225. % and anything other than special (case-sensitive), it
  226. % will be ignored.
  227. \newcounter{problem}
  228. \newcommand{\specialsymbol}{$\bigstar$ }
  229. \newlength{\specialsymbollength}
  230. \settowidth{\specialsymbollength}{\specialsymbol}
  231. \newenvironmentx{problem}[2][1={},2={},usedefault]{%
  232.     \refstepcounter{problem}%
  233.     \Writetofile{shortsolutions}{\protect\hypertarget{soln:\theproblem:\thechapter}{}}%
  234.     \needspace{\baselineskip}%
  235.     \ifthenelse{\isodd{\theproblem}}%
  236.         {%
  237.             \ifthenelse{\boolean{showoddsolns}}%
  238.             {}% true (by default)
  239.             {\setboolean{showSolution}{false}}%
  240.         }%
  241.         {%
  242.             \ifthenelse{\boolean{showevensolns}}%
  243.             {}% true (by default)
  244.             {\setboolean{showSolution}{false}}%
  245.         }%
  246.     \ifthenelse{\equal{#2}{}}%
  247.     {%  NOT special problem
  248.         % if no second argument (special or not)
  249.         \ifthenelse{\equal{#1}{}}%
  250.         {% Problem withOUT description
  251.             \ifthenelse{\boolean{showSolution}}%
  252.             {%
  253.                 {\hypertarget{prob:\theproblem:\thechapter}{}%
  254.                  {{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem}}}\newline}%
  255.             }%
  256.             {%
  257.                  {\bfseries Problem \theproblem}\newline%
  258.             }%
  259.         }%
  260.         {% Problem with description
  261.             \ifthenelse{\boolean{showSolution}}%
  262.             {%
  263.                 {\hypertarget{prob:\theproblem:\thechapter}{}%
  264.                  {{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem} \,(#1)}}\newline}%
  265.             }%
  266.             {%
  267.                  {\bfseries Problem \theproblem\, (#1) }\newline%
  268.             }%
  269.         }%
  270.     }%
  271.     {%  special problem
  272.         \ifthenelse{\equal{#2}{special}}%
  273.         {%
  274.             % write problem number to specialfile
  275.             \addcontentsline{prb}{}{\theproblem}%
  276.             \ifthenelse{\equal{#1}{}}%
  277.             {%  special problem with no description
  278.                 \ifthenelse{\boolean{showSolution}}%
  279.                 {%
  280.                     {\hypertarget{prob:\theproblem:\thechapter}{}%
  281.                      {\hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem}}}\newline}%
  282.                 }%
  283.                 {%
  284.                     \hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \theproblem}\newline%
  285.                 }%
  286.             }%
  287.             {% special problem with description
  288.                 \ifthenelse{\boolean{showSolution}}%
  289.                 {% with links
  290.                     {\hypertarget{prob:\theproblem:\thechapter}{}%
  291.                      {\hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter}{\theproblem} \,(#1)}}\newline}%
  292.                 }%
  293.                 {%  no links
  294.                      \hspace{-\specialsymbollength}\specialsymbol{\bfseries Problem \theproblem\, (#1) }\newline%
  295.                 }%
  296.             }%
  297.         }{ \textbf{Problem} \theproblem \, (#1) {\bf\huge\color{red}special?}\par}%
  298.     }%
  299. }%
  300. {%
  301. }%
  302.  
  303. % subproblem environment
  304. \newcounter{subproblem}[problem]
  305. \newboolean{specialproblemYesNo}
  306. \setboolean{specialproblemYesNo}{false}
  307. \newenvironment{subproblem}[1][]{%
  308.     \refstepcounter{subproblem}%
  309.         \ifthenelse{\isodd{\theproblem}}%
  310.         {%
  311.             \ifthenelse{\boolean{showoddsolns}}%
  312.             {}% true (by default)
  313.             {\setboolean{showSolution}{false}}%
  314.         }%
  315.         {%
  316.             \ifthenelse{\boolean{showevensolns}}%
  317.             {}% true (by default)
  318.             {\setboolean{showSolution}{false}}%
  319.         }%
  320.         \ifthenelse{\equal{#1}{special}}%
  321.         {%
  322.             \setboolean{specialproblemYesNo}{true}%
  323.         }%
  324.         {%
  325.             \setboolean{specialproblemYesNo}{false}%
  326.         }%
  327.         \ifthenelse{\boolean{specialproblemYesNo}}%
  328.         {% special problem
  329.             \addcontentsline{prb}{}{\theproblem.\thesubproblem}%
  330.             \ifthenelse{\boolean{showSolution}}%
  331.             {%  hyperlink to solution
  332.                 \hypertarget{prob:{\theproblem.\thesubproblem}:\thechapter}{}%
  333.                 \hypersetup{linkcolor=black}%
  334.                 \begin{enumerate}[label=\llap{$\bigstar$ }\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem,leftmargin=*]
  335.                 \item%
  336.             }%
  337.             {%  no hyperlink
  338.                 \begin{enumerate}[label=\llap{$\bigstar$ }\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem,leftmargin=*]
  339.                 \item%
  340.             }%
  341.         }%
  342.         {% NOT special problem
  343.             \ifthenelse{\boolean{showSolution}}%
  344.             {%  hyperlink to solution
  345.                 \hypertarget{prob:{\theproblem.\thesubproblem}:\thechapter}{}%
  346.                 \hypersetup{linkcolor=black}%
  347.                 \begin{enumerate}[label=\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem,leftmargin=*]
  348.                 \item%
  349.             }%
  350.             {%  no hyperlink
  351.                 \begin{enumerate}[label=\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem,leftmargin=*]
  352.                 \item%
  353.             }%
  354.         }%
  355.         }{\end{enumerate}}
  356.  
  357.  
  358. % definition
  359. \theoremstyle{break}
  360. \theoremsymbol{}
  361. \theoremseparator{}
  362. \theoremprework{\FloatBarrier}
  363. \def\theoremframecommand{%
  364.       \psshadowbox[fillstyle=solid,fillcolor=yellow,linecolor=black]}
  365. \newshadedtheorem{pccdefinition}{Definition}%[chapter]
  366. %   END CUSTOM THEOREMS (for examples, problems)
  367.  
  368. %   BEGIN special PROBLEMS
  369. \newcounter{probSectCounter}
  370. \setcounter{probSectCounter}{-1}
  371. \newcounter{probCounter}
  372. \setcounter{probCounter}{0}%
  373. \newcounter{echo}
  374. \newread\File
  375.  
  376. % redefine the \section command to increment probSectCounter
  377. % note that this could also be done for \subsection if desired
  378. \let\oldsection\section
  379. \renewcommand\section{%
  380.             \stepcounter{probSectCounter}%
  381.             %\addcontentsline{prb}{heading\theprobSectCounter}%
  382.             \addcontentsline{prb}{}{heading\theprobSectCounter}%
  383.             \oldsection}
  384.  
  385. \makeatletter
  386.  
  387. % need a command to bring the \contentsline
  388. % into the problemlist environment
  389. \let\pcc@contentslist\contentsline%
  390. \newenvironment{problemlist}%
  391. {%
  392.     % renew the \contentsline command so that it just gives
  393.     % the problem number as a hyperlink (and no page number)
  394.     %
  395.     % if we renewed the command outside of the environment, it would
  396.     % affect \tableofcontents, \minitoc, and perhaps more- bad!
  397.     \let\contentsline\pcc@contentslist%
  398.     \let\Contentsline\contentsline%
  399.     \renewcommand\contentsline[4]{%
  400.     \StrCount{##2}{heading}[\heading]%
  401.     \ifthenelse{\heading>0}%
  402.     {%
  403.         \StrCount{##2}{heading\theprobSectCounter}[\heading]%
  404.         \ifthenelse{\heading>0}%
  405.         {%
  406.             \setcounter{echo}{1}%
  407.             \setcounter{probCounter}{0}%
  408.         }%
  409.         {%
  410.             \setcounter{echo}{0}%
  411.         }%
  412.     }%
  413.     {%
  414.         \ifthenelse{\equal{\theecho}{1}}%
  415.         {%
  416.             \stepcounter{probCounter}%
  417.             \ifthenelse{\equal{\theprobCounter}{1}}%
  418.             {%
  419.                 % if we're at the beginning, no comma
  420.                 Special problems in this section (\specialsymbol\unskip): \Contentsline{##1}{##2}{}{##4}%
  421.             }%
  422.             {%
  423.                 % otherwise put a comma and a space
  424.                 \unskip, \Contentsline{##1}{##2}{}{##4}%
  425.             }%
  426.         }%
  427.         {}%
  428.     }%
  429.     }%
  430. }%
  431. {}
  432.  
  433. \def\listspecialproblems{%
  434. % open the appropriate file do everything in a
  435. % new environment so that we can renew the
  436. % \contentsline command locally
  437. \begin{problemlist}
  438. \par%
  439. \openin\File=\jobname.prb%
  440. \loop\unless\ifeof\File%
  441. \read\File to\fileline%
  442. \fileline%
  443. \repeat%
  444. \closein\File%
  445. \end{problemlist}
  446. }%
  447.  
  448. % enable the \jobname.prb file
  449. % (hacked from the ntheorem package)
  450. \def\prb@enablelistofproblems{%
  451. \begingroup%
  452. \makeatletter%
  453. \if@filesw%
  454. \expandafter\newwrite\csname tf@prb\endcsname%
  455. \immediate\openout \csname tf@prb\endcsname \jobname.prb\relax%
  456. \fi%
  457. \@nobreakfalse%
  458. \endgroup}%
  459.  
  460. % enable the \jobname.prb<counter> files at the end
  461. % of the document
  462. \AtEndDocument{\prb@enablelistofproblems}
  463.  
  464. \makeatother
  465.  
  466. %   END special PROBLEMS
  467.  
  468. %   BEGIN TABLE STYLES
  469. \renewcommand{\heavyrulewidth}{0.2em}
  470. \renewcommand{\lightrulewidth}{0.1em}
  471. \renewcommand{\cmidrulewidth}{0.1em}
  472. % horizontal lines
  473. \renewcommand{\aboverulesep}{0cm}
  474. \renewcommand{\belowrulesep}{0cm}
  475. \newcommand*\heading[1]{\hfill{#1}\hfill}
  476. \newcommand*\beforeheading{\toprule}
  477. \newcommand*\afterheading{\midrule}
  478. %\newcommand*\normalline{\hline}
  479. \newcommand*\normalline{}
  480. \newcommand*\lastline{\bottomrule}
  481. %   END TABLE STYLES
  482.  
  483. %   BEGIN CUSTOMIZE SECTIONS
  484. % custom chapter
  485. \titleformat{\chapter}[display]
  486. {\normalfont\Large\filcenter\bf}
  487. {\titlerule[1pt]%
  488. \vspace{1pt}%
  489. \titlerule
  490. \LARGE\MakeUppercase{#1} \psshadowbox{\Huge\thechapter}}
  491. {1pc}
  492. {\titlerule
  493. \Huge}
  494.  
  495. % write to the solutions files to step the chapter counter
  496. \let\oldchapter\chapter
  497. \renewcommand{\chapter}{\Writetofile{shortsolutions}{\protect\stepcounter{chapter}}%
  498. \oldchapter}
  499.  
  500. % From the titlesec package
  501. % \titlespacing{command}{left spacing}{before spacing}{after spacing}[right]
  502. % spacing: how to read {12pt plus 4pt minus 2pt}
  503. %           12pt is what we would like the spacing to be
  504. %           plus 4pt means that TeX can stretch it by at most 4pt
  505. %           minus 2pt means that TeX can shrink it by at most 2pt
  506. %       This is one example of the concept of, 'glue', in TeX
  507.  
  508. \titlespacing{\chapter}{0pt}{*4}{-0.1cm}
  509. \titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{-5pt plus 2pt minus 2pt}
  510. \titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
  511. \titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt}
  512.  
  513. %   END CUSTOMIZE SECTIONS
  514.  
  515. %====================================
  516. %   BEGIN DOCUMENT
  517. %====================================
  518. \begin{document}
  519.  
  520. \renewcommand{\labelenumi}{(\alph{enumi})}
  521.  
  522. % needed for the mini-tableofcontents
  523. \dominitoc
  524. \faketableofcontents
  525.  
  526. \fancyhf{} % delete current header and footer
  527. \fancyhead[LE,RO]{\bfseries\thepage}
  528. \fancyhead[LO,RE]{\tiny\leftmark}
  529.  
  530. \pagestyle{fancy}
  531. \include{polynomialfunctions}
  532.  
  533. %=======================
  534. %   BEGIN SOLUTIONS
  535. %=======================
  536.  
  537. % change to one-sided mode
  538. % change the pagestyle to plain
  539. % change the page geometry using \newgeometry
  540. \setboolean{@twoside}{false}
  541. \pagestyle{plain}
  542. \newgeometry{left=1cm,right=1cm,showframe=true,
  543.    textheight=27cm,
  544.    top=1.5cm,bottom=1.5cm,bindingoffset=1cm}
  545.  
  546. % close the solutions files
  547. \Closesolutionfile{shortsolutions}
  548.  
  549. % SHORT solution to problem (show only odd, even, all)
  550. % Note: this renewenvironment needs to go here
  551. %       so that the answers package can still
  552. %       display correctly to the page if needed
  553. \newboolean{oddproblemnumber}
  554. \renewenvironment{shortSoln}[1]{%
  555.     \exploregroups % needed to ignore {}
  556.     % before the environment starts - this is a stretchable space
  557.     \vskip 0.1cm plus 2cm minus 0.1cm%
  558.     \fullexpandarg % need this line so that '.' are counted
  559.     %
  560.     % either problems, or subproblems, e.g: 3.1 or 3.1.4 respectively
  561.     % determine which one by counting the '.'
  562.     \StrCount{#1}{.}[\numberofdecimals]
  563.     %
  564.     % find the problem number by splitting the string
  565.     \ifthenelse{\numberofdecimals=0}%
  566.     {%
  567.         % problems, such as 4, 5, 6, ...
  568.         \def\problemnumber{#1}%
  569.     }%
  570.     {}%
  571.     \ifthenelse{\numberofdecimals=1}%
  572.     {%
  573.         % problems, such as 4.3, 1.2, 10.5
  574.         \StrBefore{#1}{.}[\problemnumber]%
  575.     }%
  576.     {}%
  577.     \ifthenelse{\numberofdecimals=2}%
  578.     {%
  579.         % subproblems such as 1.3.1, 1.2.4, 7.5.6
  580.         \StrBehind{#1}{.}[\newbit]%
  581.         \StrBefore{\newbit}{.}[\problemnumber]%
  582.      }%
  583.     {}%
  584.      %
  585.      % determine if the problem number is odd or even
  586.      % and depending on our choices above, display or not
  587.      \ifthenelse{\isodd{\problemnumber}}%
  588.      {%
  589.          % set a boolean that says the problem number is odd (used later)
  590.          \setboolean{oddproblemnumber}{true}%
  591.          % display or not
  592.          \ifthenelse{\boolean{showoddsolns}}%
  593.          {%
  594.             % if we want to show the odd problems
  595.             {\bfseries \hypertarget{soln:#1:\thechapter}{}\hyperlink{prob:#1:\thechapter}{#1}.}%
  596.          }%
  597.          {%
  598.             % otherwise don't show them!
  599.             \expandafter\comment%          
  600.          }%
  601.      }%
  602.      {%
  603.          % even numbered problem, set the boolean (used later)
  604.          \setboolean{oddproblemnumber}{false}%
  605.          \ifthenelse{\boolean{showevensolns}}%
  606.          {%
  607.             % if we want to show the even problems
  608.             {\itshape \hypertarget{soln:#1:\thechapter}{}\hyperlink{prob:#1:\thechapter}{#1}.}%
  609.          }%
  610.          {%
  611.             % otherwise don't show them!
  612.             \expandafter\comment%          
  613.          }%
  614.      }%
  615. }%
  616. {%
  617.     % after the environment finishes
  618.     \ifthenelse{\boolean{oddproblemnumber}}%
  619.     {%
  620.         % odd numbered problems
  621.          \ifthenelse{\boolean{showoddsolns}}%
  622.          {%
  623.             % if we want to show the odd problems
  624.             % then the environment is finished
  625.          }%
  626.          {%
  627.             % otherwise we need to finish the comment
  628.             \expandafter\endcomment%
  629.          }%
  630.     }%
  631.     {%
  632.         % even numbered problems
  633.          \ifthenelse{\boolean{showevensolns}}%
  634.          {%
  635.             % if we want to show the even problems
  636.             % then the environment is finished
  637.          }%
  638.          {%
  639.             % otherwise we need to finish the comment
  640.             \expandafter\endcomment%
  641.          }%
  642.     }%
  643. }
  644.  
  645.  
  646. \clearpage
  647.  
  648. % set solution figure width
  649. \newlength{\solutionfigurewidth}
  650. \setlength{\solutionfigurewidth}{3cm}
  651.  
  652. % input the SHORT solutions file
  653. \IfFileExists{shortsolutions.tex}{\input{shortsolutions.tex}}{}
  654.  
  655. %=======================
  656. %   END SOLUTIONS
  657. %=======================
  658.  
  659. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement