KTUG 한국 텍 사용자 그룹

Menu

KTUG :: 마당자유글 › minipage의 parskip이 tikz에 미치는 영향

이호재 | 2009.12.23 13:27:35 | 메뉴 건너뛰기 쓰기

질문게시판에 올려야 할 듯하지만, 문제의 원인을 알았기 때문에 달리 회피하는 방법을 취하여 일단 문제를 해결하였습니다.

재미삼아 봐주십시오.


일전에 재미삼아 만든 원문자 매크로에서 

\abnormalparskip{.25\baselineskip} 등으로 minipage안에 \parskip을 달리 설정하여 주면 \tikz\node에 영향을 준다는 것을 알게 되었습니다.


파일 첨부가 안 되나요?

컴파일 해 보시고 각 단락에서 박스의 높이의 차이에 주목해 주시기 바랍니다.


\documentclass[openany,9pt,showtrims]{memoir} 
%\usepackage{hoze-style}
\usepackage{ifluatex}
\usepackage{xkeyval}
\usepackage{xifthen}
\usepackage{xcolor}
\usepackage{tikz}

\makeatletter
\newcommand\wrapnumfont{\wrapnumbf}
\newcommand\wrapnumbf{\bfseries}
\newcommand\wrapnumbase{}
\newlength\wrapnumwidth
\newlength\wrapsep
\setlength\wrapsep{1.5pt}
\newcommand\wrapbgcolor{black}
\newcommand\wrapfgcolor{white}

\newcommand\cirnum[1]{%  
   \raisebox{-.25\baselineskip}{
   \tikz\node[%
   circle, draw=\wrapfgcolor, thin, inner sep=.1\wrapsep,
   top color=\wrapbgcolor, bottom color=\wrapbgcolor,
text width=\wrapnumwidth, 
font=\wrapnumfont, text badly centered, \wrapfgcolor
]{#1};%
   }%
}


\newcommand\ovalnum[1]{%  
   \raisebox{-.15\baselineskip}{
   \tikz\node[%  
   rectangle, draw=\wrapfgcolor, thin, inner sep=\wrapsep,
   rounded corners=3pt,
   top color=\wrapbgcolor, bottom color=\wrapbgcolor,
text width=\wrapnumwidth, 
font=\wrapnumfont, text badly centered, \wrapfgcolor
]{#1};%
   }%
}

\newcommand\recnum[1]{%  
   \raisebox{-.15\baselineskip}{
   \tikz\node[%
   rectangle, draw=\wrapfgcolor, thin, inner sep=\wrapsep,
   top color=\wrapbgcolor, bottom color=\wrapbgcolor,
text width=\wrapnumwidth, 
font=\wrapnumfont, text badly centered, \wrapfgcolor
]{#1};%
   }%
}

\define@key{wrapnum}{base}{%
\renewcommand\wrapnumbase{#1}%
\setwrapnumwidth%
}
\define@key{wrapnum}{font}{%
\renewcommand\wrapnumfont{\wrapnumbf#1}%
\setwrapnumwidth%
}

\newcommand\setwrapnumwidth{%
\settowidth\wrapnumwidth{\wrapnumfont\wrapnumbase}%
}

\define@key{wrapnum}{type}[circle]{%
\ifthenelse{\equal{#1}{circle}}{\let\wrapnum\cirnum}{}%
\ifthenelse{\equal{#1}{rectangle}}{\let\wrapnum\recnum}{}%
\ifthenelse{\equal{#1}{oval}}{\let\wrapnum\ovalnum}{}%
}

\define@key{wrapnum}{background}{
\renewcommand\wrapbgcolor{#1}
}

\define@key{wrapnum}{foreground}{
\renewcommand\wrapfgcolor{#1}
}

\define@key{wrapnum}{color}{%
\ifthenelse{\equal{#1}{white}}{%
\renewcommand\wrapbgcolor{white}%
\renewcommand\wrapfgcolor{black}%
\renewcommand\wrapnumbf{}%
}{}%
\ifthenelse{\equal{#1}{black}}{%
\renewcommand\wrapbgcolor{black}%
\renewcommand\wrapfgcolor{white}%
\renewcommand\wrapnumbf{\bfseries}%
}{}%
}

\define@key{wrapnum}{wrapseparate}{%
\setlength\wrapsep{#1}%
}

\newcommand\setwrapnum[1]{%
\setkeys{wrapnum}{#1}%
}

\setwrapnum{%
type=rectangle,
base=99,
}

\ifluatex
\newcommand\wrapchar[2][]{%
  \setwrapnum{#1}
  \@wrapchar#2|%
}
\def\@wrapchar#1|{%
 \directlua{%
    local utf8 = unicode.utf8
    str = "#1"
    for i=1, utf8.len(str) do
     char=utf8.sub(str, i, i)
     if char==' ' then
     macro = "\string\\hspace{0.25em}"
     else
     macro = "\string\\wrapnum{"..char.."}\string\\hspace{-0.25em}"
     end
     tex.print(macro)
    end
 }%
}
\fi
\makeatother

\begin{document}

\wrapchar[type=rectangle, color=black]{There's a lady who's sure all that glitters is gold when she's buying a stairway to heaven.}
There's a lady who sure all that glitters is gold when she's buying a stairway to heaven.

\bigskip

\abnormalparskip{.25\baselineskip}
\wrapchar[type=rectangle, color=black]{There's a lady who's sure all that glitters is gold when she's buying a stairway to heaven.}
There's a lady who sure all that glitters is gold when she's buying a stairway to heaven.

\abnormalparskip{2ex}
\wrapchar[type=rectangle, color=black]{There's a lady who's sure all that glitters is gold when she's buying a stairway to heaven.}
There's a lady who sure all that glitters is gold when she's buying a stairway to heaven.

\end{document}

댓글 [1]

댓글 쓰기

목록 삭제

KTUG 한국 텍 사용자 그룹