Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions TeXmacs/plugins/latex/progs/convert/latex/tmtex.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1588,10 +1588,10 @@

(define (tmtex-decode-color s . force-html)
(with cm (if (string-starts? s "#") "HTML" (named-color->xcolormap s))
(cond ((and (== cm "none") (nnull? force-html))
(cond ((== cm "HTML")
(string-append "#" (html-color->latex-xcolor s)))
((and (== cm "none") (nnull? force-html))
(tmtex-decode-color (get-hex-color s) force-html))
((and (== cm "HTML") (nnull? force-html))
`((!option "HTML") ,(html-color->latex-xcolor s)))
((== cm "texmacs")
(when (nin? s tmtex-colors)
(set! tmtex-colors (append (list s) tmtex-colors)))
Expand All @@ -1607,7 +1607,7 @@
(define (tmtex-make-color val arg)
(with ltxcolor (tmtex-decode-color val #t)
(if (list? ltxcolor)
`(!group (!append (color ,@ltxcolor) ,arg))
`(!group (!append (color ,@ltxcolor) (!group ,arg)))
`(tmcolor ,ltxcolor ,arg))))

(define (post-process-math-text t)
Expand Down
8 changes: 4 additions & 4 deletions TeXmacs/progs/convert/latex/tmtex.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1588,10 +1588,10 @@

(define (tmtex-decode-color s . force-html)
(with cm (if (string-starts? s "#") "HTML" (named-color->xcolormap s))
(cond ((and (== cm "none") (nnull? force-html))
(cond ((== cm "HTML")
(string-append "#" (html-color->latex-xcolor s)))
((and (== cm "none") (nnull? force-html))
(tmtex-decode-color (get-hex-color s) force-html))
((and (== cm "HTML") (nnull? force-html))
`((!option "HTML") ,(html-color->latex-xcolor s)))
((== cm "texmacs")
(when (nin? s tmtex-colors)
(set! tmtex-colors (append (list s) tmtex-colors)))
Expand All @@ -1607,7 +1607,7 @@
(define (tmtex-make-color val arg)
(with ltxcolor (tmtex-decode-color val #t)
(if (list? ltxcolor)
`(!group (!append (color ,@ltxcolor) ,arg))
`(!group (!append (color ,@ltxcolor) (!group ,arg)))
`(tmcolor ,ltxcolor ,arg))))

(define (post-process-math-text t)
Expand Down
40 changes: 40 additions & 0 deletions TeXmacs/tests/tmu/201_100.tmu
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<TMU|<tuple|1.1.0|2026.2.1-rc5>>

<style|<tuple|generic|chinese|table-captions-above|number-europe|preview-ref>>

<\body>
<\equation*>
<with|color|red|d d d> d d d
</equation*>

<\equation*>
<with|color|#a66|d d d>d d d
</equation*>

<\equation*>
<with|color|blue|d d d> d d d
</equation*>

\;

\;

\\[ {\\color{red}{d d d}} d d d \\]

\\[ {\\color[HTML]{AA6666}d d d} d d d \\]

\\[ {\\color{blue}{d d d}} d d d \\]

\;

\;

\;
</body>

<\initial>
<\collection>
<associate|page-medium|paper>
<associate|page-screen-margin|false>
</collection>
</initial>
19 changes: 19 additions & 0 deletions devel/201_100.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# [201_100] 公式带前景色时,使用部分颜色时导出 LaTex 代码会出错

## 如何测试

测试文件 `/mogan/TeXmacs/tests/tmu/201_100.tmu `
原本复制到 LaTeX 效果
```
\[ {\color{red}{d d d}} d d d \]
\[ {\color[HTML]{AA6666}d d d} d d d \]
\[ {\color{blue}{d d d}} d d d \]
```

预期的正确效果
复制到 LaTeX 效果
```
\[ {\color{red}{d d d}} d d d \]
\[ {\color{#AA6666}{d d d}} d d d \]
\[ {\color{blue}{d d d}} d d d \]
```