chuxuezhe_longma 2024-07-23 10:15 采纳率: 33.3%
浏览 2
已结题

latex编译出现错误


\usepackage{tcolorbox}
\tcbuselibrary{most}

\newtcolorbox{mybox}[2][]
{enhanced,
    breakable,
    sharp corners,
    rounded corners=northwest,
    colframe={darkblue},colback={titlecolor},
    fonttitle=\bfseries\large\sffamily \heiti,
    frame hidden,
    title=#2,
    attach boxed title to top left= {yshift = -3pt},
    boxed title size=standard,
    boxed title style={
        empty,
        rounded corners=north,
        toprule=0pt,
        boxrule=0pt,
        bottom=0pt,    toprule  = -1pt,rightrule=0pt,
    },
    underlay boxed title={
        \filldraw[rounded corners=\kvtcb@arc, darkblue, line width=.7mm]
        (title.south east)--++
        (93:\tcboxedtitleheight)--++ (183:\tcboxedtitlewidth)--++
        (-87:\tcboxedtitleheight)|-cycle;
    },
        #1
    }
    \makeatother

出现错误:

img

Why is happened!

  • 写回答

3条回答 默认 最新

  • GISer Liu 2024-07-23 10:22
    关注

    该回答引用自GPT-3.5, 由博主 GISer Liu 编写:

    好的,我们来详细分析并解决这个问题。首先,我们需要仔细检查代码并定位错误。

    问题分析

    用户在使用 tcolorbox 宏包时遇到了编译错误。我们需要检查以下几个方面:

    1. 宏包加载:确保 tcolorbox 宏包正确加载。
    2. 语法检查:检查代码中是否有语法错误。
    3. 环境设置:确保环境设置正确。

    代码审查

    \usepackage{tcolorbox}
    \tcbuselibrary{most}
    
    \newtcolorbox{mybox}[2][]
    {enhanced,
        breakable,
        sharp corners,
        rounded corners=northwest,
        colframe={darkblue},colback={titlecolor},
        fonttitle=\bfseries\large\sffamily \heiti,
        frame hidden,
        title=#2,
        attach boxed title to top left= {yshift = -3pt},
        boxed title size=standard,
        boxed title style={
            empty,
            rounded corners=north,
            toprule=0pt,
            boxrule=0pt,
            bottom=0pt,    toprule  = -1pt,rightrule=0pt,
        },
        underlay boxed title={
            \filldraw[rounded corners=\kvtcb@arc, darkblue, line width=.7mm]
            (title.south east)--++
            (93:\tcboxedtitleheight)--++ (183:\tcboxedtitlewidth)--++
            (-87:\tcboxedtitleheight)|-cycle;
        },
            #1
        }
        \makeatother
    

    错误定位

    1. 宏包加载\usepackage{tcolorbox}\tcbuselibrary{most} 看起来是正确的。
    2. 语法检查
      • colframe={darkblue},colback={titlecolor}titlecolor 可能未定义。
      • underlay boxed title 部分:\kvtcb@arc\tcboxedtitleheight 可能未定义。

    解决方案

    1. 定义颜色:确保 titlecolordarkblue 已定义。
    2. 修正未定义的变量:修正 \kvtcb@arc\tcboxedtitleheight

    修改后的代码

    \documentclass{article}
    \usepackage{tcolorbox}
    \tcbuselibrary{most}
    
    % 定义颜色
    \definecolor{darkblue}{RGB}{0,0,128}
    \definecolor{titlecolor}{RGB}{255,255,255}
    
    \newtcolorbox{mybox}[2][]
    {enhanced,
        breakable,
        sharp corners,
        rounded corners=northwest,
        colframe=darkblue,colback=titlecolor,
        fonttitle=\bfseries\large\sffamily \heiti,
        frame hidden,
        title=#2,
        attach boxed title to top left= {yshift = -3pt},
        boxed title size=standard,
        boxed title style={
            empty,
            rounded corners=north,
            toprule=0pt,
            boxrule=0pt,
            bottom=0pt,    toprule  = -1pt,rightrule=0pt,
        },
        underlay boxed title={
            \filldraw[rounded corners=3mm, darkblue, line width=.7mm]
            (title.south east)--++
            (93:1cm)--++ (183:3cm)--++
            (-87:1cm)|-cycle;
        },
            #1
        }
    

    解释

    1. 定义颜色:使用 \definecolor 定义 darkbluetitlecolor
    2. 修正未定义的变量:在 underlay boxed title 部分,将 \kvtcb@arc 替换为 3mm,将 \tcboxedtitleheight\tcboxedtitlewidth 替换为具体数值。

    总结

    通过以上修改,确保了颜色和变量的正确性,从而解决了编译错误。用户可以复制修改后的代码进行测试。希望这个解决方案能帮助到您!

    如果该回答解决了您的问题,请采纳!如果没有,请私信联系或评论您的疑惑

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 7月31日
  • 已采纳回答 7月23日
  • 创建了问题 7月23日

悬赏问题

  • ¥15 Opencv(C++)异常
  • ¥15 VScode上配置C语言环境
  • ¥15 汇编语言没有主程序吗?
  • ¥15 这个函数为什么会爆内存
  • ¥15 无法装系统,grub成了顽固拦路虎
  • ¥15 springboot aop 应用启动异常
  • ¥15 matlab有关债券凸性久期的代码
  • ¥15 lvgl v8.2定时器提前到来
  • ¥15 qtcp 发送数据时偶尔会遇到发送数据失败?用的MSVC编译器(标签-qt|关键词-tcp)
  • ¥15 cam_lidar_calibration报错