我不确定这是否是正确的描述。我有应用于整个文档的默认字体。并且我有一个在命令 \teacher{} 中调用的字体。
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pgf,tikz}
\begin{document}
\newcommand{\cur}[1]{{\fontfamily{qzc}\selectfont #1}}
\begin{center}
{\Huge \color{blue!90!green!50}{\textbf{Title}}}
\end{center}
\bigskip
\newcommand{\teacher}[1]{
\tikz[baseline]{
\draw (0,0) node[left=0.3cm,align=center,fill=violet!20,draw=violet,rounded corners,line width=2pt,inner sep=5pt] {\cur{#1}}
}
}
\newcommand{\lteacher}[1]{
\tikz[baseline]{
\draw (0,0) node[left=0.3cm,align=center,fill=violet!20,draw=violet,rounded corners,line width=2pt,inner sep=5pt] {#1}
}
}
Normal text.\\
\bigskip
%test%
\teacher{This is line 1.\\ This is line 2.}\\
\bigskip
\lteacher{\cur{This is line 1.}\\ \cur{This is line 2.}}
\end{document}
我想要的是能够在第一个命令 \teacher{} 而不是 \lteacher 内进行换行。
答案1
在节点选项中使用font=\fontfamily{qzc}\selectfont
。它将字体应用于多行节点的所有行。
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pgf,tikz}
\begin{document}
\newcommand{\cur}[1]{{\fontfamily{qzc}\selectfont #1}}
\newcommand{\teacher}[1]{%
\tikz[baseline]{%
\draw (0,0) node[left=0.3cm,align=center,fill=violet!20,draw=violet,rounded corners,line width=2pt,
inner sep=5pt,
font=\fontfamily{qzc}\selectfont %<<<<<<<<<<<<<<<<<<
] {#1}
}
}
\newcommand{\lteacher}[1]{%
\tikz[baseline]{%
\draw (0,0) node[left=0.3cm,align=center,fill=violet!20,draw=violet,rounded corners,line width=2pt,inner sep=5pt] {#1}
}
}
Normal text.\\
\bigskip
%test%
\teacher{This is line 1.\\ This is line 2.}\\
\bigskip
\lteacher{\cur{This is line 3.}\\ \cur{This is line 4.}}
\end{document}