옆에있는 parbox의 높이와 정확히 일치하는 수직선을 그리는 방법
Dec 04 2020
섹션 이름과 세로줄이 콘텐츠 옆에 있어야하는 cv에 대한 작은 섹션을 만들려고합니다. 섹션 이름은 중앙에 있어야하고 수직선은 콘텐츠의 높이와 정확히 일치해야합니다. 다음은 원하는 출력입니다.

이제 내 코드를 사용하여 .NET Framework의 높이를 정확히 얻기 위해 수직선 높이를 설정하는 방법을 모르겠습니다 \parbox
. 이것이 데모를 위해 1cm로 설정 한 이유입니다. 누구든지 내 코드를 약간 수정하거나이를 달성하는 더 나은 방법으로 원하는 출력을 얻는 방법을 알고 있습니까?
\documentclass[12pt]{standalone}
\usepackage{tikz}
\newcommand{\lorem}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
\newcommand{\customsection}[2]{
\begin{minipage}{0.05\textwidth}
\rotatebox[origin=c]{90}{#1}
\hspace{0.01cm}
\begin{tikzpicture}
\fill [bottom color=red, top color=blue] (0cm, 0cm) rectangle (-0.05cm, 1cm);
\end{tikzpicture}
\end{minipage}
\parbox[c]{0.85\textwidth}{
#2
}
}
\begin{document}
\customsection{TEST}{\lorem \\ \lorem \\ \lorem}
\end{document}
나는 또한 나를 위해 작동하지 않은 parbox 높이에 액세스하려고 시도 했습니다. \ parbox의 액세스 높이
미리 감사드립니다.
내 출력 :

답변
4 RuixiZhang Dec 04 2020 at 20:57
다음 코드는 어떻습니까? 문서는 주석으로 코드에 제공됩니다.
\documentclass[12pt]{standalone}
\usepackage{tikz}
\newcommand{\lorem}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
% Define owmal's box to store the \parbox
\newsavebox\owmalsbox
% Notice where `%' are added to suppress end-of-line spaces!
\newcommand{\customsection}[2]{%
% First we save \parbox into \owmalsbox.
% We also use \strut both at the beginning and at the end,
% and this will ensure that the first line and the last line
% have the same height (in most cases).
\sbox\owmalsbox{%
\parbox[c]{0.85\textwidth}{%
\strut#2\strut
}%
}%
% The total height of the \parbox is now available as
% \the\ht\owmalsbox+\the\dp\owmalsbox, so we can put our
% side-way text at (\the\ht\owmalsbox+\the\dp\owmalsbox)/2,
% and draw our rectangle accordingly. The minipage has the
% optional argument `c' to go with `\parbox[c]...' above.
% Notice again the use of \strut in the side-way text.
\begin{minipage}[c]{0.05\textwidth}
\begin{tikzpicture}
\node [rotate=90, above] at
(-0.05cm, {(\the\ht\owmalsbox+\the\dp\owmalsbox)/2})
{\strut#1};
\fill [bottom color=red, top color=blue]
(0cm, 0cm)
rectangle
(-0.05cm, \the\ht\owmalsbox+\the\dp\owmalsbox);
\end{tikzpicture}%
\end{minipage}%
% The following additional space depends on how you setup
% the minipage (it is 0.05\textwidth wide for now).
% Adjust these if necessary.
\hspace{0.5cm}%
% Finally we typeset \owmalsbox by releasing its content
% (and also destroy its content).
\unhbox\owmalsbox
}
\begin{document}
\customsection{TEST}{\lorem \\ \lorem \\ \lorem}
\end{document}
