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
2 changes: 1 addition & 1 deletion TeXmacs/progs/convert/latex/latex-define.scm
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
(tmcodeinline ((!option "") (!group (ttfamily) (!group 2))))

;; Binary macros
(tmcolor (!group (color 1) (!group 2)))
(tmcolor (textcolor 1 2))
(tmsummarizeddocumentation
(trivlist (!append (item (!option "")) (mbox "") "\\large\\bf" 1)))
(tmsummarizedgrouped (trivlist (!append (item (!option "[")) (mbox "") 1)))
Expand Down
6 changes: 3 additions & 3 deletions TeXmacs/progs/convert/latex/latex-drd.scm
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@
(captionof "capt-of")
(widthof "calc")

(color "xcolor")
(fcolorbox "xcolor")
(textcolor "xcolor")
(color "xcolor")
(fcolorbox "xcolor")
(textcolor "xcolor")

(euro "eurosym")

Expand Down
6 changes: 4 additions & 2 deletions TeXmacs/progs/convert/latex/tmtex.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,8 @@
(cond ((and (== cm "none") (nnull? force-html))
(tmtex-decode-color (get-hex-color s) force-html))
((and (== cm "HTML") (nnull? force-html))
(when (nin? cm tmtex-colormaps)
(set! tmtex-colormaps (append (list cm) tmtex-colormaps)))
`((!option "HTML") ,(html-color->latex-xcolor s)))
((== cm "texmacs")
(when (nin? s tmtex-colors)
Expand All @@ -1607,8 +1609,8 @@
(define (tmtex-make-color val arg)
(with ltxcolor (tmtex-decode-color val #t)
(if (list? ltxcolor)
`(!group (!append (color ,@ltxcolor) ,arg))
`(tmcolor ,ltxcolor ,arg))))
`(textcolor ,@ltxcolor ,arg)
`(textcolor ,ltxcolor ,arg))))

(define (post-process-math-text t)
(cond ((or (nlist? t) (!= (length t) 2)) t)
Expand Down
16 changes: 16 additions & 0 deletions devel/203_27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# #3035 Fix LaTeX color export for partially styled formulas

## 2026/03/25 Update LaTeX export for colored expressions

### What
Updated LaTeX export for colored expressions to use \textcolor and ensured proper xcolor package handling for HTML colors.

### Why
- Replaces fragile \color usage with scoped \textcolor, preventing color leakage
- Ensures correct behavior in both text and math mode
- Fixes missing xcolor inclusion for HTML (hex) colors

### How
- Updated tmtex-make-color in tmtex.scm to use \textcolor
- Fixed HTML color handling in tmtex-decode-color
- Aligned macro definitions in latex-define.scm with the new approach