2

When I use something like \[\textcolor{White}{\contour{green}{\alpha}}\] the alpha comes out in green, not white, and has no outline whatsoever. How can I fix this? I want it to be in white with a green outline.

Thanks for your help.

MWE

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb,amsmath,amsthm}
\usepackage[runin]{abstract}
\usepackage{titlesec}
\usepackage{titlecaps}
\usepackage{fancyhdr}
\usepackage{breqn}
\usepackage{bm}
\usepackage[english]{babel}
\usepackage[outline]{contour}
\usepackage{geometry} %Geometry package to change the text width
\geometry{textwidth=8cm} %8cm Text width
\usepackage[dvipsnames]{xcolor}

\begin{document} [\textcolor{White}{\contour{green}{\alpha}}] \end{document}


EDIT

I just realized that actually it does work-although only partially. I was just zoomed out so I didn't notice the difference in color. HOWEVER, it doesn't let the maths be written like it usually is with \[...\]; it only outputs the maths the size of \(...\) even when I explicitly use \[...\].

  • As far as I know, it can only be done with pstricks – more precisely, the \pscharpath command from pst-text has this possibility. – Bernard Jun 01 '21 at 14:54
  • @Bernard please could you elaborate a bit? I'm not a very advacned LaTeX user. I'll add \usepackage{pstricks}, then what? – A-Level Student Jun 01 '21 at 15:01
  • I'm sorry, I've just tested, and there seems to be problems with mathmode, which is new to me. It used to work a few years ago. I don't have time at the moment, but I'll take a look this evening. – Bernard Jun 01 '21 at 15:29
  • @Bernard Thanks so much! – A-Level Student Jun 01 '21 at 15:43
  • Personally, I don't think so, as there aren't so many questions on this topic, as far as I know, and your code might be helpful. – Bernard Jun 01 '21 at 17:36
  • @Bernard ok, thanks. However, there's another problem that I just realized; please see my edit. Sorry to keep bothering you. – A-Level Student Jun 01 '21 at 17:38
  • You don't bother me. For a letter, the size is the same for in-line and displaystyle formula, so I don't see what the problem is. – Bernard Jun 01 '21 at 17:41
  • @Bernard Eg \prod and \sum come out small. – A-Level Student Jun 01 '21 at 19:18
  • 1
    If you want larger \pro and \sum, you add \displaystyle on entering math mode. There's also the \mathlarger command from package relsize. – Bernard Jun 01 '21 at 19:46

2 Answers2

5

Works in pdflatex only. However, for other possibilities, see Outline text using TrueType fonts. Here, one can control the colors and the outline thickness as settable parameters.

\documentclass{article}
\usepackage{xcolor}
\input pdf-trans
\newbox\qbox
\def\usecolor#1{\csname\string\color@#1\endcsname\space}
\newcommand\bordercolor[1]{\colsplit{1}{#1}}
\newcommand\fillcolor[1]{\colsplit{0}{#1}}
\newcommand\outline[1]{\leavevmode%
  \def\maltext{#1}%
  \setbox\qbox=\hbox{\maltext}%
  \boxgs{Q q 2 Tr \thickness\space w \fillcol\space \bordercol\space}{}%
  \copy\qbox%
}
\newcommand\colsplit[2]{\colorlet{tmpcolor}{#2}\edef\tmp{\usecolor{tmpcolor}}%
  \def\tmpB{}\expandafter\colsplithelp\tmp\relax%
  \ifnum0=#1\relax\edef\fillcol{\tmpB}\else\edef\bordercol{\tmpC}\fi}
\def\colsplithelp#1#2 #3\relax{%
  \edef\tmpB{\tmpB#1#2 }%
  \ifnum `#1>`9\relax\def\tmpC{#3}\else\colsplithelp#3\relax\fi
}
\begin{document}
\bordercolor{black}
\fillcolor{white}
\def\thickness{.1}
\outline{$\alpha$}

\def\thickness{0.15} \bordercolor{blue!70!black} \fillcolor{yellow} \outline{$\alpha$}

\bordercolor{green!70!black} \fillcolor{white} \def\thickness{.2}

$x\outline{$\alpha$}y$ \end{document}

enter image description here

2

You can change graphic state at PDF primitive level. PDF includes commands for filling characters or stroking or both. The 0 Tr means only filling (it is default) and 2 Tr means filling plus stroking. The line width of stroking is given by num w. The colors can be set independently for filling (rg for RGB or k for CMYK) and for stroking (RG or K).

Your task seems like this from PDF primitive point of view:

\pdfliteral{1 1 0 rg 1 0 0 RG 2 Tr .2 w}% yellow filing, red stroking
$\alpha + b = c$ % the formula has yellow symbols with red outlines.
\pdfliteral{0 g 0 G 0 Tr 0 w}%
Normal text in black follows.

\bye

wipet
  • 74,238