Forgot password?
 Create new account
View 2709|Reply 0

关于《撸题集》里的♠♡♣♢

[Copy link]

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2016-1-11 15:04:36 |Read mode
大家应该都留意到我的《kuing网络撸题集》里用于题目间隔的 $\spadesuit\ \heartsuit\ \clubsuit\ \diamondsuit$ 在每一节内是循环出现的,我的实现方法如下,代码并不深,应该很容易理解。
  1. \documentclass{article}
  2. \usepackage{amsthm}
  3. \newtheorem{problem}{problem}[section]
  4. \newcommand\tmtop[1]{\ifcase#1\or
  5. \begin{center}$\spadesuit$\end{center}\or
  6. \begin{center}$\heartsuit$\end{center}\or
  7. \begin{center}$\clubsuit$\end{center}\or
  8. \begin{center}$\diamondsuit$\end{center}\fi}
  9. \newcounter{tmtopctr}
  10. \newcommand\puttmtop{\tmtop{\value{tmtopctr}}%
  11. \ifnum\value{tmtopctr}<4\relax
  12. \addtocounter{tmtopctr}{1}%
  13. \else\setcounter{tmtopctr}{1}\fi}
  14. \newenvironment{prob}{%
  15. \ifnum\value{problem}=0\relax
  16. \setcounter{tmtopctr}{0}\fi
  17. \puttmtop
  18. \begin{problem}}{\end{problem}}
  19. \begin{document}
  20. \section{test1}
  21. \begin{prob}
  22. aaa
  23. \end{prob}
  24. \begin{prob}
  25. bbb
  26. \end{prob}
  27. \begin{prob}
  28. ccc
  29. \end{prob}
  30. \begin{prob}
  31. ddd
  32. \end{prob}
  33. \begin{prob}
  34. eee
  35. \end{prob}
  36. \begin{prob}
  37. fff
  38. \end{prob}
  39. \begin{prob}
  40. ggg
  41. \end{prob}
  42. \begin{prob}
  43. hhh
  44. \end{prob}
  45. \begin{prob}
  46. iii
  47. \end{prob}
  48. \begin{prob}
  49. jjj
  50. \end{prob}
  51. \section{test2}
  52. \begin{prob}
  53. kkk
  54. \end{prob}
  55. \begin{prob}
  56. lll
  57. \end{prob}
  58. \begin{prob}
  59. mmm
  60. \end{prob}
  61. \end{document}
Copy the Code

手机版Mobile version|Leisure Math Forum

2025-4-21 01:03 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list