2
\documentclass{article}%https://github.com/readme/featured/nasa-ingenuity-helicopter
\usepackage[left=1cm, right=1cm, top=1cm, bottom=1cm]{geometry} 
\usepackage[T1]{fontenc}
\usepackage{cascadia-code}
%\usepackage{paratype}\renewcommand{\familydefault}{\sfdefault}
\usepackage{xcolor}
\usepackage{gradient-text}
\usepackage[most]{tcolorbox}
\definecolor{backgroundd}{HTML}{232629}
\definecolor{myblue}{HTML}{1B1F23}
\newtcbox{\mybox}[1][myblue]{tcbox width=auto limited,colback=#1, colframe=#1, boxsep=0pt, size=small, arc=2mm, boxrule=10.4pt, top=2mm,bottom=2mm, right=2mm, left=2mm}
\newcommand{\cooltext}[1]{
  {\fontfamily{\sfdefault}\selectfont 
\mybox{\Large\bf\gradientRGB{#1}{72,107,234}{60,214,112}}
  }
}


\begin{document}
a DSFASDF ASDF 
ASD SAD FASD FSAD AS ASD 


\cooltext{We wanted to make sure everyone was recognized for their contributions to this incredible human achievement.}

{\fontfamily{\sfdefault}\selectfont
This text uses a different font typeface
}
 
\end{document}

I want to change font ONLY in tcbox (all other text shoult be defaul style or family) and achieve such result enter image description here

Thank you for any help

2 Answers 2

1

Your \cooltext command does (the equivalent of) \sffamily which is a declaration only subject to grouping. Since you issue it at the top level, its effect goes on forever.

You need to issue \sffamily inside the box.

I suggest to make the font choice when defining the tcbox, and to change its name to a more semantic one than \mybox.

Finally, note that \bf has been a deprecated command for about thirty years.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{gradient-text}
\usepackage[many]{tcolorbox}

\definecolor{backgroundd}{HTML}{232629}
\definecolor{myblue}{HTML}{1B1F23}

\newtcbox{\cooltextbox}[1][myblue]{
  tcbox width=auto limited,
  fontupper=\Large\sffamily\bfseries,
  colback=#1,
  colframe=#1,
  boxsep=0pt,
  size=small,
  arc=2mm,
  boxrule=10.4pt,
  top=2mm,
  bottom=2mm,
  right=2mm,
  left=2mm,
}

\newcommand{\cooltext}[1]{%
  \cooltextbox{%
    \gradientRGB{#1}{72,107,234}{60,214,112}%
  }%
}


\begin{document}

Normal text

\cooltext{We wanted to make sure everyone was recognized for their 
contributions to this incredible human achievement.}

Normal text
 
\end{document}

enter image description here

1
  • yes, that is what I wanted to achieve, thank you Commented Sep 7, 2023 at 10:29
2

I have changed the sequence of cooltext command. That makes the text outside its purview to be different.

\documentclass{article}%https://github.com/readme/featured/nasa-ingenuit
\usepackage[left=1cm, right=1cm, top=1cm, bottom=1cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{cascadia-code}
%\usepackage{paratype}\renewcommand{\familydefault}{\sfdefault}
\usepackage{xcolor}
\usepackage{gradient-text}
\usepackage[most]{tcolorbox}
\definecolor{backgroundd}{HTML}{232629}
\definecolor{myblue}{HTML}{1B1F23}
\newtcbox{\mybox}[1][myblue]{tcbox width=auto limited,colback=#1, colfra
\newcommand{\cooltext}[1]{%
\mybox{\Large\sffamily\bfseries\gradientRGB{#1}{72,107,234}{60,214,112}}
}

\begin{document}
a DSFASDF ASDF
ASD SAD FASD FSAD AS ASD

\cooltext{We wanted to make sure everyone was recognized for their contributions to this incredible human achievement.}

{\sffamily
This text uses a different font typeface
}

\end{document}

enter image description here

2
  • Copy paste issues :-( Updated.
    – mas
    Commented Sep 7, 2023 at 5:20
  • thank you for your answer Commented Sep 7, 2023 at 10:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .