MWE

MWE

계속 내이전 질문\scalebox: 로고의 크기를 특정 높이로 조절하여 사용할 수 있는 방법이 있나요 ? Tikz에서 만든 로고를 Tikz에서 만든 직사각형에 넣고 싶습니다. 둘 다 장 헤더로 사용해야 합니다. \savebox로고를 미리 저장하는 명령을 사용했습니다 . 하지만 이제 로고의 높이가 직사각형과 같고 둘 다 동일한 원점을 갖기를 원합니다. height of the rectangle / \ht\logo어떻게 든 스케일링 인수와 같은 표현식을 사용할 수 있습니까 ? 로고가 변경되면 도움이 될 것입니다. 코드는 다음과 같습니다. 변경이 필요하다고 생각되는 선이 표시되어 있습니다.

\documentclass[a4paper,11pt,fleqn]{book}
\usepackage{xcolor}
\usepackage{color}
\definecolor{mydarkgray}{RGB}{0,100,100}
\newcommand{\mytemplatecolor}{mydarkgray}

\usepackage{tikz}

\newsavebox{\logo}
\savebox{\logo}{%
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\path[draw=black,fill=black,line join=miter,line cap=round,miter
limit=4.00,nonzero rule,dash phase=3.000pt,line width=0.000pt]
(178.4915,651.0411) .. controls (178.0358,651.0411) and (177.5801,651.0411)..
 (177.1244,651.0411) .. controls (177.1244,652.6787) and (177.1244,654.3163) ..
 (177.1244,655.9539) .. controls (177.5801,655.9539) and (178.0358,655.9539) ..
 (178.4915,655.9539) .. controls (178.4915,654.3163) and (178.4915,652.6787) ..
 (178.4915,651.0411) -- cycle;
 \path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
 cap=round,miter limit=4.00,nonzero rule,dash phase=3.000pt,line
width=0.000pt,rounded corners=0.0000cm] (-182.0794,658.5070) rectangle
(-177.1244,660.6401);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,nonzero rule,dash phase=3.000pt,line width=0.000pt,rounded
corners=0.0000cm] (-280.8165,679.2454) rectangle (-193.6939,684.6964);
\path[xscale=-1.000,yscale=1.000,fill=black,nonzero rule,rounded
corners=0.0000cm] (-280.8165,694.2955) rectangle (-177.1245,696.3244);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,miter limit=4.00,nonzero rule,dash phase=3.000pt,line
width=0.000pt,rounded corners=0.0000cm] (-280.8165,716.4833) rectangle
(-177.1245,721.9073);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,nonzero rule,dash phase=3.000pt,line width=0.000pt,rounded
corners=0.0000cm] (-185.6345,669.1724) rectangle (-177.1244,673.9126);
\end{tikzpicture}}

\usepackage[explicit]{titlesec}
 \newcommand*\chapterlabel{}
\titleformat{\chapter}[display]  
{\Huge\bfseries\sffamily\color{\mytemplatecolor}}
{\gdef\chapterlabel{\thechapter\ }}    
{0pt} % separation between label and chapter-title
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-8cm,xshift=0cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
    \draw[name path=mainbox,fill=\mytemplatecolor,\mytemplatecolor] (0,0)        rectangle(35.5mm,15mm);% mainbox
    \path (0,0) ++(0.379\wd\logo,+0.3755\ht\logo) node {\scalebox{0.76}  {\usebox{\logo}}};% this works if i would finetune the settings. But i want the Logo to always appear with the exakt height of the mainbox and flush with the page boarder. No tiny overlap anywere as this looks bad when zooming inside the PDF
\node[anchor=north east,yshift=-7.2cm,xshift=34mm,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{15mm}{\raggedleft $\phantom{\textrm{l}}$\color{white}\chapterlabel}};  
\node[anchor=north west,yshift=-7.2cm,xshift=37mm,text     width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north west)
    {\parbox[top][30mm][t]{\textwidth}{\color{\mytemplatecolor}#1}};
    \end{tikzpicture}
};
\gdef\chapterlabel{} % code before the title body
\end{tikzpicture}
}
\titlespacing*{\chapter}{-98pt}{38pt}{30pt} % [A]


\begin{document}
\chapter{A Chapter} 

\end{document}  

그렇지 않다면 어떻게든 로고 크기를 출력하여 정확한 비율을 수동으로 계산할 수 있습니까? 를 사용하여 특정 높이를 mm 단위로 지정할 수 있습니까 \scalebox?

답변1

egreg에서 제안한 것처럼 을 사용할 수 있습니다 . \resizebox처럼 작동하며 \scalebox축척 계수 대신 축척 차원을 사용합니다.

\resizebox{<width dim>}{<height dim>}{contents to be scaled}

종횡비를 유지하면서 특정 너비/높이로 크기를 조정하려는 경우. 이를 위해 !종속 차원에 제공합니다 . 예를 들어 귀하의 경우에는 다음과 같습니다.

\resizebox{!}{<rectangle height>}{\usebox{\logo}}

\scalebox따라서 부품 을 교체 \resizebox{!}{15mm}{\usebox{\logo}}하면 스케일링 문제가 사라집니다.

이제 위치 지정에 몇 가지 문제가 있고 도면 자체에 몇 가지 문제가 있습니다. 첫 번째 얇은 것은 배경 직사각형이며 \draw채우기 옵션과 함께 사용하므로 로고 위치를 지정할 때 처리해야 \pgflinewidth하지만 선과 채우기가 동일한 색상이므로 필요가 없으며 대신 \draw사용하면 선이 발생하지 않습니다. \path더 이상 그려지지 마세요.

이제 로고가 포함된 노드로 이동합니다. 중앙에 위치하므로 로고의 크기가 변경될 때마다 그에 따라 위치를 변경해야 합니다. anchor=south west(옵션과 동일 ) 을 사용 하고 이제 노드의 '원본'이 에 있는 above right노드를 배치합니다 . 하지만 노드에는 기본적으로 내부 sep가 있으므로 이를 0: 으로 설정해야 합니다 . 또한 노드 주위에 너비가 있는 기본 상자가 있어 로고와 배경 상자 사이에 간격이 남습니다. 이 작은 공간을 제거하도록 또는 설정 (더 똑똑함) 을 수행할 수 있습니다 . 따라서 모든 작업을 수행한 후에는 그림이 괜찮을 것입니다.at (0,0)(0,0)inner sep=0pt\pgflinewidthshift={(45:-\pgflinewidth)}line width=0pt

600% 줌

MWE

\documentclass[a4paper,11pt,fleqn]{book}
\usepackage{xcolor}
\usepackage{color}
\definecolor{mydarkgray}{RGB}{0,100,100}
\newcommand{\mytemplatecolor}{mydarkgray}

\usepackage{tikz}
\usetikzlibrary{intersections}

\newsavebox{\logo}
\savebox{\logo}{%
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\path[draw=black,fill=black,line join=miter,line cap=round,miter
limit=4.00,nonzero rule,dash phase=3.000pt,line width=0.000pt]
(178.4915,651.0411) .. controls (178.0358,651.0411) and (177.5801,651.0411)..
 (177.1244,651.0411) .. controls (177.1244,652.6787) and (177.1244,654.3163) ..
 (177.1244,655.9539) .. controls (177.5801,655.9539) and (178.0358,655.9539) ..
 (178.4915,655.9539) .. controls (178.4915,654.3163) and (178.4915,652.6787) ..
 (178.4915,651.0411) -- cycle;
 \path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
 cap=round,miter limit=4.00,nonzero rule,dash phase=3.000pt,line
width=0.000pt,rounded corners=0.0000cm] (-182.0794,658.5070) rectangle
(-177.1244,660.6401);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,nonzero rule,dash phase=3.000pt,line width=0.000pt,rounded
corners=0.0000cm] (-280.8165,679.2454) rectangle (-193.6939,684.6964);
\path[xscale=-1.000,yscale=1.000,fill=black,nonzero rule,rounded
corners=0.0000cm] (-280.8165,694.2955) rectangle (-177.1245,696.3244);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,miter limit=4.00,nonzero rule,dash phase=3.000pt,line
width=0.000pt,rounded corners=0.0000cm] (-280.8165,716.4833) rectangle
(-177.1245,721.9073);
\path[xscale=-1.000,yscale=1.000,draw=black,fill=black,line join=miter,line
cap=round,nonzero rule,dash phase=3.000pt,line width=0.000pt,rounded
corners=0.0000cm] (-185.6345,669.1724) rectangle (-177.1244,673.9126);
\end{tikzpicture}}

\usepackage[explicit]{titlesec}
 \newcommand*\chapterlabel{}
\titleformat{\chapter}[display]  
{\Huge\bfseries\sffamily\color{\mytemplatecolor}}
{\gdef\chapterlabel{\thechapter\ }}    
{0pt} % separation between label and chapter-title
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-8cm,xshift=0cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
    \path[name path=mainbox,fill=\mytemplatecolor,\mytemplatecolor] (0,0)        rectangle (35.5mm,15mm);% mainbox
    \node[line width=0pt, above right=0mm, draw=none, inner sep=0pt] at (0,0) {\resizebox{!}{15mm}{\usebox{\logo}}};
\node[anchor=north east,yshift=-7.2cm,xshift=34mm,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{15mm}{\raggedleft $\phantom{\textrm{l}}$\color{white}\chapterlabel}};  
\node[anchor=north west,yshift=-7.2cm,xshift=37mm,text     width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north west)
    {\parbox[top][30mm][t]{\textwidth}{\color{\mytemplatecolor}#1}};
    \end{tikzpicture}
};
\gdef\chapterlabel{} % code before the title body
\end{tikzpicture}
}
\titlespacing*{\chapter}{-98pt}{38pt}{30pt} % [A]


\begin{document}
\chapter{A Chapter} 

\end{document}  

관련 정보