Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. documentclass[12pt,a4paper]{book}
  2. usepackage{answers}
  3. usepackage{amsthm}
  4. usepackage{hyperref}
  5. usepackage{tcolorbox}
  6. usepackage{ifthen}
  7. usepackage{tikz}
  8. usetikzlibrary{shadows}
  9.  
  10. tikzstyle{buttonstyle} = [rectangle, fill = black!30, draw = black!80, drop shadow, font={sffamilybfseries}, text=white]
  11.  
  12. newcommand*{button}[1]{tikz{node[buttonstyle] {#1};}}
  13.  
  14. theoremstyle{definition}
  15. newtheorem{ex}{%
  16. hypertarget{sol:theex}{ } hfill
  17. hyperlink{ex:theex}{button{Solution}}\
  18. phantomsection
  19. }[chapter]
  20. Newassociation{sol}{Soln}{corr}
  21. renewenvironment{Soln}[1]
  22. {parbigskipnoindentphantomsection{bfseries hypertarget{ex:#1}{}
  23. {bfseries Solution of exercise #1}hfill
  24. hyperlink{sol:#1}{button{Back to exercise #1}}\}quad}
  25. {parbigskip}
  26.  
  27. % Usage MEExercise[keys]{exercise}{solution}
  28. newcommandMEExercise[3][]{
  29. ifthenelse{equal{#3}{}}
  30. { % The no solution case
  31. }
  32. { %Have a solution
  33. begin{tcolorbox}
  34. begin{ex}
  35. #2
  36. begin{sol}
  37. #3
  38. end{sol}
  39. end{ex}
  40. end{tcolorbox}
  41. }
  42. }
  43.  
  44. begin{document}
  45. chapter{This}
  46. Opensolutionfile{corr}[ans1]
  47. section{Problems}
  48. begin{tcolorbox}
  49. begin{ex}
  50. First exercise.
  51. begin{sol}
  52. First solution.
  53. end{sol}
  54. end{ex}
  55. end{tcolorbox}
  56.  
  57. %MEExercise{this is exercise 1}{this is solution of exercise 1}
  58. chapter{That}
  59. %newpage
  60. begin{ex}
  61. Second exercise.
  62. begin{sol}
  63. Second solution.
  64. end{sol}
  65. end{ex}
  66. %MEExercise{this is exercise 2}{this is solution of exercise 2}
  67. %newpage
  68. Closesolutionfile{corr}
  69. %newpage
  70. section{Solutions}
  71. input{ans1}
  72. end{document}
  73.  
  74. begin{Soln}{1.1}
  75. First solution.
  76. end{Soln}
  77. begin{Soln}{1.2}
  78. this is solution of exercise 1 end {sol} end {ex} end {tcolorbox}
  79. chapter{That}
  80. %newpage
  81. begin{ex}
  82. Second exercise.
  83. begin{sol}
  84. Second solution.
  85. end{Soln}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement