TransWikia.com

Modify the attributes of a circle

TeX - LaTeX Asked on August 24, 2021

Question:

How can I modify the following code so that it takes 2 more arguments (background color, and font color)?

MWE:

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{tikz}
usetikzlibrary{arrows}
usetikzlibrary{shapes}

newcommand*circled[1]{tikz[baseline=(char.base)]{
            node[shape=circle,draw,inner sep=2pt] (char) {#1};}}


begin{document}
    
circled{+}
    
end{document}

Current Output:

enter image description here

Ideal Output:

circled{+}{#00d131}{#ffffff} would yield:

enter image description here

FWIW:

I’m open to other suggestions if the above MWE is not the optimum method for such tasks.

One Answer

Try this, and more details please read this link and this for how to define a command with and without optional arguments.

newcommand*circled[3]{
    definecolor{fill_color}{HTML}{#2}
    tikz[baseline=(char.base)]{
        node[shape=circle, fill=fill_color, draw,inner sep=2pt] (char) {textcolor[HTML]{#3}{#1}};}}

circled{+}{00d131}{ffff3f}

Correct answer by Amita on August 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP