0

The result of \itshape or \textit{} is the italics of the main font in our document. If I have other fonts set for different environments, I could access their italics by the use of \fooitalics via a definition of \newfontfamily{\fooitalics}[Path]{someitalics.ttf}. But how can I use italic fonts in a new command which is designed to be workable in different environments with different environment specific fonts?

For example, I want a new command \qqit to use double quotes symbol and make text to be italic, if I define it as \newcommand{\qqit}[1]{{\itshape\qq{#1}}}, then it works in the environment which uses the main font, but doesn't work for other environments with other fonts.

\usepackage{xeCJK}
\usepackage[T1]{fontenc}
\usepackage{domitian}  % for the main font
\newfontfamily{\notefont}[Path=./fonts/]{LinBiolinum.ttf}  % for note environment
\newfontfamily{\notefontitalic}[Path=./fonts/]{LinBiolinum_Italic.ttf}
\usepackage[most, minted]{tcolorbox}
\usepackage{changepage}
\tcolorboxenvironment{note}{blanker, breakable, before skip=6pt,after skip=16pt, borderline west={1mm}{0pt}{myblue}}
    \newenvironment{note}{\begin{adjustwidth}{3mm}{0mm}}{\end{adjustwidth}}

\usepackage{textcmds} % qq for double quotes \newcommand{\qqit}[1]{{\itshape\qq{#1}}}

\begin{note} In this note, the \qqit{notefont} is used. \end{note} In this paragraph, the \qqit{main font} is used.

enter image description here

The first "notefont" is not italics as the main font is not used in that environment.

If I change the command to \newcommand{\qqit}[1]{{\notefontitalic\qq{#1}}}, then it uses the 'notefont_italic.ttf' other than the main font italics for "main font": enter image description here

Kumar
  • 25
  • 4

1 Answers1

0

You shouldn't be doing \usepackage{domitian} with XeLaTeX to begin with. The font is also available as OpenType.

Since I have installed both Linux Biolinum O and Domitian as system fonts, the calls below might have to be adapted to your setting. The main aspect is that you need to properly define a single font family for Biolinum (or, better, use \setsansfont).

\documentclass{article}

\usepackage{xeCJK} \usepackage[many]{tcolorbox} \usepackage{changepage} \usepackage{textcmds} % qq for double quotes

\colorlet{myblue}{blue!60!green} \tcolorboxenvironment{note}{ blanker, breakable, before skip=6pt, after skip=16pt, borderline west={1mm}{0pt}{myblue}, } \newenvironment{note} {\begin{adjustwidth}{3mm}{0mm}\notefont} {\end{adjustwidth}}

\newcommand{\qqit}[1]{\textit{\qq{#1}}}

\setmainfont{Domitian}

\newfontfamily{\notefont}{Linux Biolinum O}

\begin{document}

\begin{note} In this note, the \qqit{notefont} is used. \end{note}

In this paragraph, the \qqit{main font} is used.

\end{document}

Production notes: I removed minted from the libraries because I didn't want to bother with shell escape; I also provided a definition for the myblue color.

enter image description here

egreg
  • 1,121,712