平均能量损失

平均能量损失

继续我的上一个问题:有没有办法使用\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}  

如果不行,我能以某种方式输出徽标的尺寸来手动计算精确的比例吗?我可以用 指定一个具体的高度(以毫米为单位)吗\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)并放置节点at (0,0),现在节点的“原点”位于(0,0)。但是默认情况下,节点有一些内部分隔符,我们必须将其设置为 0:。inner sep=0pt此外,节点周围有一个宽度为的底层框\pgflinewidth,这会在徽标和背景框之间留下间隙。您可以使用shift={(45:-\pgflinewidth)}或设置line width=0pt(这更智能)来删除这个小空间。所以,完成所有这些之后,绘图应该没问题。

600% 缩放

平均能量损失

\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}  

相关内容