26 Star 102 Fork 29

xkwxdyy / exam-zh

 / 详情

答案添加颜色

已完成
创建于  
2022-02-08 21:03

原帖由 @Minyang2021 发布在 https://gitee.com/zepinglee/exam-zh/issues/I4SQLI#note_8567080_link

还有一个问题就是,显示答案的括号里面和横线上面能不能加个颜色,好区分开来,更醒目。

评论 (1)

zepinglee 创建了任务
zepinglee 通过 xkwxdyy/exam-zh Commit 696a15a任务状态待办的 修改为已完成
展开全部操作日志

我曾经统一包装过\uline\CJKunderline,重定义了\underline,可以分别控制内容和下划线的颜色,下划线的厚度,可以参考:

\documentclass{ctexart}
\usepackage{xcolor}
\usepackage{xeCJKfntef}

\ExplSyntaxOn

\tl_new:N \l__coloruline_line_color_tl
\tl_new:N \l__coloruline_text_color_tl
\dim_new:N \l__coloruline_line_width_dim

\keys_define:nn { coloruline }
  {
    textcolor .tl_set:N = \l__coloruline_text_color_tl,
    textcolor .initial:n = black,
    linecolor .tl_set:N = \l__coloruline_line_color_tl,
    linecolor .initial:n = black,
    line-width .dim_set:N = \l__coloruline_line_width_dim,
    line-width .initial:n = 0.4pt,
    thickness .dim_set:N = \l__coloruline_line_width_dim,
    thickness .initial:n = 0.4pt,
  }


\NewDocumentCommand{ \coloruline } { O{} m }
  {
    \group_begin:
      \keys_set:nn { coloruline } {#1}
      \bgroup
        \color{ \tl_use:N \l__coloruline_text_color_tl }
        \markoverwith
        {
          \textcolor
            { \tl_use:N \l__coloruline_line_color_tl }
            { \rule[-0.5ex]{2pt}{ \l__coloruline_line_width_dim } }
        }
        \ULon{#2}
    \group_end:
  }


\NewDocumentCommand{ \colorCJKuline }{ O{} m }
  {
    \group_begin:
      \keys_set:nn { coloruline } {#1}
      \CJKunderline
        [
          format = { \color{\l__coloruline_line_color_tl} },
          textformat = { \color{\l__coloruline_text_color_tl} },
          thickness = \l__coloruline_line_width_dim
        ]
        {#2}
    \group_end:
  }


\RenewDocumentCommand{ \underline }{ s O{} m }
  {
    \IfBooleanTF {#1}
      {
        \colorCJKuline[#2]{#3}
      }
      {
        \coloruline[#2]{#3}
      }
  }
\ExplSyntaxOff

\begin{document}

\underline[textcolor = red, linecolor = blue]{
  这是一段中文测试,具体测试什么呢,想测试uline的中文支持,看看能否换行
}

\underline{
  When we published our data analysis of the security questions on Stack Overflow and the Information Security Stack Exchange back in October, we found that every time that there was a major vulnerability or breach, there would be a corresponding uptick in the number of questions asked. It made intuitive sense, but the data confirmed it. But we didn’t expect to have new data to confirm this trend so soon. 
}

\underline*[thickness = 1pt]{
  这是一段中文测试,具体测试什么呢,想测试uline的中文支持,看看能否换行
}

\underline*[line-width = 1pt]{
  When we published our data analysis of the security questions on Stack Overflow and the Information Security Stack Exchange back in October, we found that every time that there was a major vulnerability or breach, there would be a corresponding uptick in the number of questions asked. It made intuitive sense, but the data confirmed it. But we didn’t expect to have new data to confirm this trend so soon. 
}
\end{document}

输入图片说明

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
7693572 billxdyy 1640995361 780258 zepinglee 1634743500
TeX/LaTeX
1
https://gitee.com/xkwxdyy/exam-zh.git
git@gitee.com:xkwxdyy/exam-zh.git
xkwxdyy
exam-zh
exam-zh

搜索帮助