Advertisement
Guest User

HyperFAIL

a guest
Feb 25th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 5.74 KB | None | 0 0
  1. \documentclass{article}
  2.  
  3. \usepackage{answers}                            
  4. \usepackage{enumitem}                      
  5. \usepackage{hyperref}
  6. \usepackage{multicol}
  7. \usepackage{changepage}
  8. \usepackage{etoolbox}
  9.  
  10. \newcommand\getcurrentref[1]{%
  11.  \ifnumequal{\value{#1}}{0}
  12.  {??}
  13.  {\the\value{#1}}%
  14. }    
  15.  
  16. \hypersetup{colorlinks=true}
  17.  
  18. \setlength{\parindent}{0.0mm}
  19.  
  20.  
  21. % very useful during de-bugging!
  22. %\usepackage[left]{showlabels}
  23. %\showlabels{hypertarget}
  24. %\showlabels{hyperlink}
  25.  
  26. % solutions files
  27. % short solutions
  28. \Opensolutionfile{shortsolutions}
  29. \Newassociation{shortsolution}{shortSoln}{shortsolutions}
  30. \Newassociation{short}{shortSolns}{shortsolutions}
  31. % long solutions
  32. \Opensolutionfile{longsolutions}
  33. \Newassociation{longsolution}{longSoln}{longsolutions}
  34. \Newassociation{longs}{longsSolns}{longsolutions}
  35.  
  36. % new environment that sets up hypertargets both in the question
  37. % section, and in the answer section
  38. \newlist{myenum}{enumerate}{3}
  39. \newcounter{question}[subsection]
  40. \newenvironment{question}[1]%
  41.     {%
  42.     \refstepcounter{question}%
  43.     %  hyperlink to solution
  44.          \hypertarget{question:{\thesubsection\thequestion}}{}%
  45.          \Writetofile{shortsolutions}{\protect\hypertarget{shortsoln:\thesubsection\thequestion}{}}%
  46.          \Writetofile{longsolutions}{\protect\hypertarget{longsoln:\thesubsection\thequestion}{}}%
  47.          \begin{myenum}[label=\bfseries\protect\hyperlink{shortsoln:\thesubsection\thequestion}{\thequestion.},ref=\thequestion]
  48.          \item%
  49.             \hypersetup{linkcolor=black}%
  50.             \hyperlink{longsoln:\thesubsection\thequestion}{#1}%
  51.         }%
  52.         {%
  53.         \end{myenum}}
  54.  
  55. \newenvironment{IntList}[1]{%
  56. \Opensolutionfile{mysolutions}
  57. \centering
  58. \setlength{\columnsep}{50pt}
  59. \begin{adjustwidth}{-3em}{-2em}\begin{multicols}{#1}}{\end{multicols}\end{adjustwidth}\Closesolutionfile{mysolutions}}
  60.  
  61.  
  62. \begin{document}
  63.  
  64. \section{Problems}
  65.  
  66. \subsection{Questions}
  67. \begin{multicols}{3}
  68.  
  69.                 \begin{short}
  70.                \vspace*{\baselineskip}
  71.                \color{white} hello
  72.                \vspace*{-\baselineskip}
  73.            \end{short}
  74.            \begin{longs}
  75.                 \vspace*{\baselineskip}
  76.                \color{white} hello
  77.                \vspace*{-\baselineskip}
  78.            \end{longs}
  79.  
  80.    \begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
  81.            \begin{shortsolution}
  82.                $-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
  83.            \end{shortsolution}
  84.            \begin{longsolution}
  85.                In order to do this, we must first make a substitution\ldots
  86.            \end{longsolution}
  87.    \end{question}
  88.    \begin{question}{$\int(2x-1)^{50}\mathrm{d}x$}
  89.            \begin{shortsolution}
  90.                $\frac{1}{102}(2x-1)^{51}+C$
  91.            \end{shortsolution}
  92.            \begin{longsolution}
  93.                A very long solution| much longer than the shorter solution
  94.            \end{longsolution}
  95.    \end{question}
  96.    \begin{question}{$\int\sqrt[n]{x}\mathrm{d}x$}
  97.            \begin{shortsolution}
  98.                $\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
  99.            \end{shortsolution}
  100.            \begin{longsolution}
  101.                Even longer!
  102.                Even longer!
  103.                Even longer!
  104.                Even longer!
  105.                Even longer!
  106.                Even longer!
  107.                Even longer!
  108.                Even longer!
  109.                Even longer!
  110.                Even longer!
  111.                Even longer!
  112.            \end{longsolution}
  113.    \end{question}
  114. \end{multicols}
  115.  
  116. \subsection{Some more questions}
  117.  
  118. \begin{multicols}{3}
  119.  
  120.                 \begin{short}
  121.                \vspace*{\baselineskip}
  122.                \color{white} hello
  123.                \vspace*{-\baselineskip}
  124.            \end{short}
  125.            \begin{longs}
  126.                 \vspace*{\baselineskip}
  127.                \color{white} hello
  128.                \vspace*{-\baselineskip}
  129.            \end{longs}
  130.  
  131.    \begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
  132.            \begin{shortsolution}
  133.                $-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
  134.            \end{shortsolution}
  135.            \begin{longsolution}
  136.                hi
  137.            \end{longsolution}
  138.    \end{question}
  139.    \begin{question}{$\int(2x-1)^{50}\mathrm{d}x$}
  140.            \begin{shortsolution}
  141.                $\frac{1}{102}(2x-1)^{51}+C$
  142.            \end{shortsolution}
  143.            \begin{longsolution}
  144.                ho
  145.            \end{longsolution}
  146.    \end{question}
  147.    \begin{question}{$\int\sqrt[n]{x}\mathrm{d}x$}
  148.            \begin{shortsolution}
  149.                $\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
  150.            \end{shortsolution}
  151.            \begin{longsolution}
  152.               lets go
  153.            \end{longsolution}
  154.    \end{question}
  155.  
  156. \end{multicols}
  157.  
  158. \begin{huge}
  159. Input files / include files here
  160. \end{huge}
  161.  
  162. % close solution files
  163. \Closesolutionfile{shortsolutions}
  164. \Closesolutionfile{longsolutions}
  165.  
  166.  
  167. \clearpage
  168. \section{SHORT answers}
  169. % renew the SHORT solution environment so that it hyperlinks back to
  170. % the question
  171. \renewenvironment{shortSoln}[1]{%
  172.          % add some glue
  173.          \vskip .5cm plus 2cm minus 0.1cm%
  174.          {\bfseries \hyperlink{question:#1}{#1.}}%
  175. }%
  176. {%
  177. }%
  178. % input the file if it exists
  179. \IfFileExists{shortsolutions.tex}{\input{shortsolutions.tex}}{}
  180.  
  181. \clearpage
  182. \section{LONG answers}
  183. % renew the LONG solution environment so that it hyperlinks back to
  184. % the question
  185. \renewenvironment{longSoln}[1]{%
  186.          % add some glue
  187.          \vskip .5cm plus 2cm minus 0.1cm%
  188.          {\bfseries \hypersetup{linkcolor=blue}\hyperlink{question:#1}{#1.}}%
  189. }%
  190. {%
  191. }%
  192. % input the file if it exists
  193. \IfFileExists{longsolutions.tex}{\input{longsolutions.tex}}{}
  194. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement