(현재 경계 상자.북쪽)과 함께 사용되는 yshift/xshift

(현재 경계 상자.북쪽)과 함께 사용되는 yshift/xshift

다음 코드는 매뉴얼에서 나온 것입니다 pgf.

Top align:
\tikz[baseline=(current bounding box.north)]
\draw (0,0) rectangle (1cm,1ex);

이 위치(현재 경계 box.north)의 기준선을 3pt만큼 올리려고 하므로 yshift다음과 같이 시도했습니다.

Top align:
\tikz[baseline=[yshift=3pt](current bounding box.north)]
\draw (0,0) rectangle (1cm,1ex);

하지만 컴파일을 통과하지 못합니다.

내 질문에 도움을 줄 수 있는 사람이 있나요?

MWE:

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\begin{document}
Top align:
    \tikz[baseline=(current bounding box.north)]
    \draw (0,0) rectangle (1cm,1ex);
\end{document}

답변1

내 의견을 변환하고 확장하겠습니다.

  • 를 사용하여 위치 정의current bounding box
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
Top align:
    \tikz[baseline={([yshift=1ex] current bounding box.north)}]
    \draw (0,0) rectangle (1cm,1ex);
\end{document}

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

참고: shift일부 좌표는 좌표가 작성된 부모 내부에 있어야 했습니다: ([yshift=...] <coordinate>). 좌표 가 대괄호 안의 옵션( tikzpicturesome 의 결정에 대한 또는 결정 )으로 제공되는 경우 위의 MWE에서 수행된 것처럼 중괄호로 캡슐화해야 합니다.\coordinate

  • 다음을 사용하지 않고 위치 정의 current bounding box:
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
Aligned with a text    
    \tikz[baseline]
    \draw (0,0) rectangle (1cm,1ex);
and displaced for some amount:
    \tikz[baseline=2ex]
    \draw (0,0) rectangle (1cm,1ex);

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

관련 정보