
저는 TikZ를 사용하여 선형 조합 및 관련 항목을 인쇄하는 매크로를 작성했습니다( pgffor
실제로는 큰 문서의 다른 항목에는 TikZ가 필요합니다). MWE는 다음과 같습니다.
\documentclass[11pt]{article}
\usepackage{tikz,spalign,xspace,amsmath}
\newcommand\lincomb[3]{% 3args: list of coeffs, vector symb, operation
% \begin{tikzpicture}
\tikz{
\foreach \x [count=\j] in {#1}{
\ifnum\j=1
$\x{#2}_{\j}$
\else
${#3}\x{#2}_{\j}$
\fi
}\xspace
% \end{tikzpicture}
}
}
\begin{document}
\begin{equation}
\spalignmat{0.7;0.5;0.1}={\lincomb{0.7,0.5,0.1}{\mathbf{e}}{+}}\quad
\;\text{and}\:
\spalignmat{0.1;0.5;0.7}=\lincomb{0.1,0.5,0.7}{\mathbf{e}}{+}
\end{equation}
$\lincomb{a,b,c}{f}{-}$ and then some text.
\begin{tikzpicture}
\foreach \x [count=\j] in {a,b,c,d}{
\ifnum\j=1
$\x f_{\j}$
\else
$+ \x f_{\j}$
\fi
}
\end{tikzpicture}\ and then some text
\end{document}
출력은 마지막에 있습니다. 내가 원하는 것은 이들 중 두 개 사이에 적절한 간격을 두는 것입니다. 보시다시피 코드를 독립형 텍스트로 사용해 보았지만 결과는 동일했습니다. 환경 도 사용해 보았지만 tikzpicture
아무런 변화가 없습니다. 검색 후 다음과 같은 질문을 많이 보았습니다.제거하다뒤에 공백이 tikzpicture
있지만 추가하고 싶습니다. 보시다시피 xspace
여기서도 작동하지 않습니다. 미리 감사드립니다!!
답변1
코드는 그리기 명령이 아니라 텍스트일 뿐이므로 tikz
또는 에 명령을 넣을 필요가 없습니다 . tikzpicture
실제로 TeX는 실제로 이러한 문자를 조판하려고 시도하고 있지만 a의 중간에 있기 때문에 문자가 전혀 없고 단어 간 공백도 생성하지 않는 내부 글꼴인 를 tikzpicture
사용하도록 지시되었습니다 . nullfont
따라서 환경 \tikz
은 tikzpicture
노드에 없기 때문에 텍스트를 삭제하면 됩니다.
\documentclass[11pt]{article}
\usepackage{tikz,spalign,amsmath}
\newcommand\lincomb[3]{% 3args: list of coeffs, vector symb, operation
% \begin{tikzpicture}
% \tikz{
\foreach \x [count=\j] in {#1}{
\ifnum\j=1
\x{#2}_{\j}
\else
{#3}\x{#2}_{\j}
\fi
% \xspace
% \end{tikzpicture}
}
}
\begin{document}
\begin{equation}
\spalignmat{0.7;0.5;0.1}={\lincomb{0.7,0.5,0.1}{\mathbf{e}}{+}}\quad
\;\text{and}\:
\spalignmat{0.1;0.5;0.7}=\lincomb{0.1,0.5,0.7}{\mathbf{e}}{+}
\end{equation}
$\lincomb{a,b,c}{f}{+}$ and then some text.
\end{document}