TikZ 그림으로 글꼴 크기 조정

TikZ 그림으로 글꼴 크기 조정

PGF 매뉴얼을 보면,

\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node (c) at (1,2) {x};
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}

의 크기를 늘리고 싶습니다 x. 문제는 동일한 다이어그램에 여러 개의 원이 있다는 것입니다. 그 중 일부는 더 큰 크기의 글꼴이 필요한 반면 다른 것들은 기본적으로 괜찮습니다. 어떻게 해야 하나요?

답변1

일반 LaTeX에서와 마찬가지로 tikZ 노드 내에서 글꼴 크기를 변경할 수 있습니다. 다음 중 하나를 사용하세요.

\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge

예를 들어

\node (c) at (1,2) {\large x};

또는

\node (c) at (1,2) {\large $x$}; %note the \large *outside* the inline math

편집하다: 글꼴 크기를 변경하려면내부에수학 모드에서 LaTeX는 다음 명령을 제공합니다.

\displaystyle
\textstyle
\scriptstyle
\scriptscriptstyle

tikZ/pgf(예: scale=...)에서 제공하는 스케일링 알고리즘을 사용하면 "전체 문자"의 스케일이 조정되므로 스케일링을 너무 많이 사용하면 보기 흉하게 보일 수 있습니다. 위 명령을 사용하여 글꼴 크기를 설정하면 LaTeX는 다양한 글꼴 크기에 대해 다른 기호를 선택합니다. 이렇게 하면 글꼴을 읽을 수 있고 충분한 "세부 정보"가 보장됩니다. 보다 극단적인 스케일링을 원할 경우 scale=3.0노드에 대한 옵션을 사용하십시오.

답변2

나중에 사용할 수 있도록 새 스타일을 설정하세요.

예를 들어:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{relsize}

\tikzset{fontscale/.style = {font=\relsize{#1}}
    }

\begin{document}
\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node (c) at (1,2) [fontscale=4] {x};
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}
\end{document}

답변3

상단에는 다음과 같이 적습니다.

\begin{tikzpicture}[thick,scale=1, every node/.style={scale=1.3}]
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node (c) at (1,2) {x};
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
        \n1 = {veclen(\x1,\y1)}
    in circle [at=(c), radius=\n1];
\end{tikzpicture}

두꺼운 것은 화살표를 변경하고, 첫 번째 스케일은 그림의 스케일을 변경하지만, 두 번째 인수는 아마도 텍스트가 있는 노드의 크기를 변경합니다. 이는 모든 노드에 대해 변경됩니다.

답변4

font명령 의 옵션을 사용할 수 있습니다 \node. 이 옵션은 (큰 글꼴 크기, 굵은 글꼴, 산세리프) font와 같은 일반적인 글꼴 명령을 허용합니다 .\node[font = {\Huge\bfseries\sffamily}, red]

여기에 이미지 설명을 입력하세요

(에서 가져옴수동.)

여기에 이미지 설명을 입력하세요

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc} 

\begin{document}

\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node[font = {\normalfont}, red] (c) at (1,2) {x}; % <=== See here!
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}

\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node[font = {\Huge\bfseries\sffamily}, red] (c) at (1,2) {x}; % <=== See here!
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}

\end{document}

\tiny
\scriptsize
\footnotesize
\small
\normalsize 
\large
\Large  
\LARGE  
\huge   
\Huge

여기에 이미지 설명을 입력하세요

(에서 가져옴수동.)

관련 정보