Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. documentclass{article}
  2.  
  3. usepackage{pgf}
  4. pgfmathsetseed{numberpdfrandomseed}
  5. usepackage{pgffor}
  6. usepackage{tikz}
  7.  
  8. pgfmathdeclarerandomlist{FracSlopes}
  9. {%
  10. {frac{1}{2}}
  11. {frac{3}{2}}
  12. {frac{5}{2}}
  13. {frac{7}{2}}
  14. {frac{1}{3}}
  15. {frac{2}{3}}
  16. {frac{4}{3}}
  17. {frac{5}{3}}
  18. {frac{7}{3}}
  19. }
  20.  
  21. pgfmathrandomitem{FracSlope}{FracSlopes}
  22.  
  23.  
  24.  
  25.  
  26. begin{document}
  27.  
  28. % Since the line below works
  29. % I know the fraction is being selected randomly.
  30. (y=FracSlope{x})
  31.  
  32. begin{tikzpicture}[scale=0.3]
  33. draw[help lines, gray, thin] (-10,-10) grid (10,10);
  34. draw[very thick,<->] (-10.3,0)--(10.3,0);
  35. draw[very thick,<->] (0,-10.3)--(0,10.3);
  36. %
  37. % Everythig compiles if the next two lines are commented out.
  38. clip (-10,-10) rectangle (10,10);
  39. draw[blue, very thick, domain=-10:10] plot (x,FracSlope*x);
  40. % It's interpreting FracSlope as a string, not a number.
  41. % I'm *pretty* sure that's the problem.
  42. end{tikzpicture}
  43.  
  44. end{document}
  45.  
  46. documentclass{article}
  47.  
  48. usepackage{tikz}
  49.  
  50. pgfmathsetseed{numberpdfrandomseed}
  51.  
  52. pgfmathdeclarerandomlist{FracSlopes}
  53. {%
  54. {mfrac{1}{2}}
  55. {mfrac{3}{2}}
  56. {mfrac{5}{2}}
  57. {mfrac{7}{2}}
  58. {mfrac{1}{3}}
  59. {mfrac{2}{3}}
  60. {mfrac{4}{3}}
  61. {mfrac{5}{3}}
  62. {mfrac{7}{3}}
  63. }
  64.  
  65. pgfmathrandomitem{FracSlope}{FracSlopes}
  66.  
  67. newcommand{mfrac}{frac}
  68. newcommand{computefrac}[2]{(#1/#2)}
  69.  
  70.  
  71. begin{document}
  72.  
  73. % Since the line below works
  74. % I know the fraction is being selected randomly.
  75. (y=FracSlope x)
  76.  
  77. begin{tikzpicture}[scale=0.3]
  78. letmfraccomputefrac
  79. draw[help lines, gray, thin] (-10,-10) grid (10,10);
  80. draw[very thick,<->] (-10.3,0)--(10.3,0);
  81. draw[very thick,<->] (0,-10.3)--(0,10.3);
  82. %
  83. % Everythig compiles if the next two lines are commented out.
  84. clip (-10,-10) rectangle (10,10);
  85. draw[blue, very thick, domain=-10:10] plot (x,{FracSlope*x});
  86. end{tikzpicture}
  87.  
  88. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement