• Latex语法学习10:盒子的使用(fbox, tcolorbox, boitee),支持设置颜色和换页


    目录

    1 \fbox

     2 彩色的盒子(可换页)

     3 boitee环境


    1 \fbox

    这段代码主要用到了三个命令:

    • \noindent:表示取消缩进
    • \textwidth:表示设置盒子宽度为页面宽度
    1. \noindent \fbox{\parbox{\textwidth}{%
    2. 子问题2:\\
    3. Maximize
    4. 43.8 Y[0,0] + 43.8 Y[0,1] + 10.5 Y[1,0] + 10.5 Y[1,1] + 33.9 Y[2,0]
    5. + 33.9 Y[2,1] + 45.9 Y[3,0] + 45.9 Y[3,1]
    6. Subject To\\
    7. R0: 37 X[0,0] + 26 X[1,0] + 28 X[2,0] + 30 X[3,0] + 24 X[4,0] + 98 Y[0,0] + 97 Y[1,0] + 37 Y[2,0] + 49 Y[3,0]
    8. <= 70\\
    9. R1: 37 X[0,1] + 26 X[1,1] + 28 X[2,1] + 30 X[3,1] + 24 X[4,1] + 98 Y[0,1] + 97 Y[1,1] + 37 Y[2,1] + 49 Y[3,1]
    10. <= 60\\
    11. R2: Y[0,0] + Y[0,1] <= 1\\
    12. R3: Y[1,0] + Y[1,1] <= 1\\
    13. R4: Y[2,0] + Y[2,1] <= 1\\
    14. R5: Y[3,0] + Y[3,1] <= 1\\
    15. Bounds\\
    16. Binaries\\
    17. X[0,0] X[0,1] X[1,0] X[1,1] X[2,0] X[2,1] X[3,0] X[3,1] X[4,0] X[4,1]
    18. Y[0,0] Y[0,1] Y[1,0] Y[1,1] Y[2,0] Y[2,1] Y[3,0] Y[3,1]\\
    19. End
    20. }}

     2 彩色的盒子(可换页)

    需要引入的环境:

    1. \usepackage[skins]{tcolorbox} %必须标注skin,才能使用shadow命令显示阴影。
    2. \tcbuselibrary{breakable} %breakable:支持跨页

    实现代码:

    • drop shadow southeast:设置阴影在东南方向
    • breakable:支持自动翻页
    • colback=red!5!white:设置背景颜色
    • colframe=red!75!black:设置外框颜色
    1. \begin{tcolorbox}[drop shadow southeast, enhanced,colback=red!5!white,colframe=red!75!black,breakable] % 在 tcolorbox 中添加 breakable 选项
    2. 子问题2:\\
    3. Maximize
    4. 43.8 Y[0,0] + 43.8 Y[0,1] + 10.5 Y[1,0] + 10.5 Y[1,1] + 33.9 Y[2,0]
    5. + 33.9 Y[2,1] + 45.9 Y[3,0] + 45.9 Y[3,1]
    6. Subject To\\
    7. R0: 37 X[0,0] + 26 X[1,0] + 28 X[2,0] + 30 X[3,0] + 24 X[4,0] + 98 Y[0,0] + 97 Y[1,0] + 37 Y[2,0] + 49 Y[3,0]
    8. <= 70\\
    9. R1: 37 X[0,1] + 26 X[1,1] + 28 X[2,1] + 30 X[3,1] + 24 X[4,1] + 98 Y[0,1] + 97 Y[1,1] + 37 Y[2,1] + 49 Y[3,1]
    10. <= 60\\
    11. R2: Y[0,0] + Y[0,1] <= 1\\
    12. R3: Y[1,0] + Y[1,1] <= 1\\
    13. R4: Y[2,0] + Y[2,1] <= 1\\
    14. R5: Y[3,0] + Y[3,1] <= 1\\
    15. Bounds\\
    16. Binaries\\
    17. X[0,0] X[0,1] X[1,0] X[1,1] X[2,0] X[2,1] X[3,0] X[3,1] X[4,0] X[4,1]
    18. Y[0,0] Y[0,1] Y[1,0] Y[1,1] Y[2,0] Y[2,1] Y[3,0] Y[3,1]\\
    19. End
    20. \end{tcolorbox}

     3 boitee环境

    需要引入的环境:

    \usepackage{boites,boites_exemples}

    盒子的内容代码:

    1. \begin{boiteepaisseavecuntitre}{ 例题1:两阶段随机规划模型的拓展式数值形式 }
    2. 95 X[0,0] + 95 X[0,1] + 51 X[1,0] + 51 X[1,1] + 77 X[2,0] + 77 X[2,1]
    3. + 50 X[3,0] + 50 X[3,1] + 65 X[4,0] + 65 X[4,1] + 17.1 Y[0,0,0]
    4. + 43.8 Y[0,0,1] + 61.6 Y[0,0,2] + 17.1 Y[0,1,0] + 43.8 Y[0,1,1]
    5. + 61.6 Y[0,1,2] + 20.1 Y[1,0,0] + 10.5 Y[1,0,1] + 27.2 Y[1,0,2]
    6. + 20.1 Y[1,1,0] + 10.5 Y[1,1,1] + 27.2 Y[1,1,2] + 6.3 Y[2,0,0]
    7. + 33.9 Y[2,0,1] + 68 Y[2,0,2] + 6.3 Y[2,1,0] + 33.9 Y[2,1,1]
    8. + 68 Y[2,1,2] + 44.7 Y[3,0,0] + 45.9 Y[3,0,1] + 6.8 Y[3,0,2]
    9. + 44.7 Y[3,1,0] + 45.9 Y[3,1,1] + 6.8 Y[3,1,2] \\
    10. Subject To \\
    11. R0: 37 X[0,0] + 26 X[1,0] + 28 X[2,0] + 30 X[3,0] + 24 X[4,0] <= 70 \\
    12. R1: 37 X[0,1] + 26 X[1,1] + 28 X[2,1] + 30 X[3,1] + 24 X[4,1] <= 60 \\
    13. R2: X[0,0] + X[0,1] <= 1 \\
    14. R3: X[1,0] + X[1,1] <= 1 \\
    15. R4: X[2,0] + X[2,1] <= 1 \\
    16. R5: X[3,0] + X[3,1] <= 1 \\
    17. R6: X[4,0] + X[4,1] <= 1 \\
    18. R7: 37 X[0,0] + 26 X[1,0] + 28 X[2,0] + 30 X[3,0] + 24 X[4,0]
    19. + 98 Y[0,0,0] + 97 Y[1,0,0] + 37 Y[2,0,0] + 49 Y[3,0,0] <= 70 \\
    20. R8: 37 X[0,0] + 26 X[1,0] + 28 X[2,0] + 30 X[3,0] + 24 X[4,0]
    21. + 98 Y[0,0,1] + 97 Y[1,0,1] + 37 Y[2,0,1] + 49 Y[3,0,1] <= 70 \\
    22. R9: 37 X[0,0] + 26 X[1,0] + 28 X[2,0] + 30 X[3,0] + 24 X[4,0]
    23. + 98 Y[0,0,2] + 97 Y[1,0,2] + 37 Y[2,0,2] + 49 Y[3,0,2] <= 70 \\
    24. R10: 37 X[0,1] + 26 X[1,1] + 28 X[2,1] + 30 X[3,1] + 24 X[4,1]
    25. + 98 Y[0,1,0] + 97 Y[1,1,0] + 37 Y[2,1,0] + 49 Y[3,1,0] <= 60 \\
    26. R11: 37 X[0,1] + 26 X[1,1] + 28 X[2,1] + 30 X[3,1] + 24 X[4,1]
    27. + 98 Y[0,1,1] + 97 Y[1,1,1] + 37 Y[2,1,1] + 49 Y[3,1,1] <= 60 \\
    28. R12: 37 X[0,1] + 26 X[1,1] + 28 X[2,1] + 30 X[3,1] + 24 X[4,1]
    29. + 98 Y[0,1,2] + 97 Y[1,1,2] + 37 Y[2,1,2] + 49 Y[3,1,2] <= 60 \\
    30. R13: Y[0,0,0] + Y[0,1,0] <= 1 \\
    31. R14: Y[0,0,1] + Y[0,1,1] <= 1 \\
    32. R15: Y[0,0,2] + Y[0,1,2] <= 1 \\
    33. R16: Y[1,0,0] + Y[1,1,0] <= 1 \\
    34. R17: Y[1,0,1] + Y[1,1,1] <= 1 \\
    35. R18: Y[1,0,2] + Y[1,1,2] <= 1 \\
    36. R19: Y[2,0,0] + Y[2,1,0] <= 1 \\
    37. R20: Y[2,0,1] + Y[2,1,1] <= 1 \\
    38. R21: Y[2,0,2] + Y[2,1,2] <= 1 \\
    39. R22: Y[3,0,0] + Y[3,1,0] <= 1 \\
    40. R23: Y[3,0,1] + Y[3,1,1] <= 1 \\
    41. R24: Y[3,0,2] + Y[3,1,2] <= 1 \\
    42. Bounds \\
    43. Binaries \\
    44. X[0,0] X[0,1] X[1,0] X[1,1] X[2,0] X[2,1] X[3,0] X[3,1] X[4,0] X[4,1] \\
    45. Y[0,0,0] Y[0,0,1] Y[0,0,2] Y[0,1,0] Y[0,1,1] Y[0,1,2] Y[1,0,0] Y[1,0,1] \\
    46. Y[1,0,2] Y[1,1,0] Y[1,1,1] Y[1,1,2] Y[2,0,0] Y[2,0,1] Y[2,0,2] Y[2,1,0] \\
    47. Y[2,1,1] Y[2,1,2] Y[3,0,0] Y[3,0,1] Y[3,0,2] Y[3,1,0] Y[3,1,1] Y[3,1,2] \\
    48. End
    49. \end{boiteepaisseavecuntitre}

    代码的执行效果:

     参考资料:

    1. 如何将LaTeX中的盒子分页? - 知乎
    2. 简单好用的可以跨页的盒子 - 无需大型宏包支持 - LaTeX 工作室

  • 相关阅读:
    深度学习(二)
    Controller层代码优化
    将labelImg生成的指定xml标签中某一类的检测框复制给其他图片的xml
    缺失找不到msvcr71.dll无法执行代码,应用程序无法启动的解决方法
    Java学习笔记5.3.1 Set接口 - HashSet类
    物联网感知-张力电子围栏及解决方案
    安装Vue脚手架
    你们看吧,一看一个不吱声
    [Linux打怪升级之路]-进程的状态
    c++动态管理
  • 原文地址:https://blog.csdn.net/weixin_45624300/article/details/127518340