第一个解决方案

第一个解决方案

我利用了标题包定义标题的自定义布局。其宽度设置为0.8\columnwidth。据我了解,在 minipage 环境中设置标题时不使用此度量。

我希望标题在小页面环境中能够按照其定义的宽度进行处理。我该如何实现?

问题是,它在没有 caption-package 的额外定义的情况下也能工作,但随后的标题就只是普通的、粗糙的左侧样式,我不太喜欢这种样式。

现状图景

在此处输入图片描述

平均能量损失

\documentclass[
11pt
]{scrartcl}

\usepackage{
tikz,
relsize,
amsmath,
booktabs,
tikz
}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}


\usepackage[
labelfont=sf,
%labelfont=sc, %Kapitälchen, passt nicht wg. nicht-osf Ziffern
%%%%labelfont=it, %italics, 
%%%labelfont=sl, %slanted,
hypcap=false,
format=hang,
%margin={2cm,2cm}
width=0.8\columnwidth
]{caption}

\usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,
decorations.pathreplacing,
decorations.pathmorphing,
decorations.shapes,
decorations.text,
shapes,
shapes.geometric,
shapes.symbols,
matrix,
patterns,
intersections,
fit}

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\tikzset{
>=latex
}

\begin{document}

\begin{figure}[btc]
%\begin{center}
\begin{minipage}[c]{0.48\columnwidth}
\begin{center}
\captionof{table}{Dataset for Something  with an Arbitrary Caption to Highlight the Problem}
\begin{tabular}{lrrrrr}
\toprule
Store & A & B & C & D & E \\
\cmidrule(r{0.125em}){1-1}%
\cmidrule(lr{0.125em}){2-2}%
\cmidrule(lr{0.125em}){3-3}%
\cmidrule(lr{0.125em}){4-4}%
\cmidrule(lr{0.125em}){5-5}%
\cmidrule(l{0.25em}){6-6}%
Input & 0.75 & 1 & 2 & 5 & 5\\
Output & 0.5 & 2 & 4 & 2 & 5\\
\bottomrule
\end{tabular}
\end{center}
\end{minipage}
\hfill
\begin{minipage}[c]{0.48\columnwidth}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small]
%
\draw[style=help lines,step=0.5cm] (0,0) grid (6,6);
%
\draw[->,thick] (-0.1,0) -- (6.5,0) node[midway,below=8pt]{Output}; %X-Achse
\draw[->,thick] (0,-0.1) -- (0,6.5) node[above=5pt]{Input}; %Y-Achse
%
\foreach \x in {0,1,...,6} \draw [thick](\x cm,-2pt) -- (\x cm,2pt);
\foreach \y in {0,1,...,6} \draw [thick](-2pt,\y) -- (2pt,\y);
%
\foreach \x in {0,1,...,6} \draw (\x cm, 0 cm) node[anchor=north]{\x} coordinate (x axis);
\foreach \y in {0,1,...,6}  \draw (0 cm, \y cm) node[anchor=east]{\y} coordinate (y axis);
%
\draw
(0,0) coordinate (orig)
(0.75,0.5) coordinate (A)
(1,2) coordinate (B)
(2,4) coordinate (C)
(5,2) coordinate (D)
(5,5) coordinate (E)
;
%
\foreach \pt/\labpos in {A/right,D/below left,E/below}{
  \fill (\pt) circle (2pt) node[\labpos=3pt,fill=white]{\pt};
};
\foreach \pt/\labpos in {B/above left,C/above left}{
  \fill (\pt) circle (3pt) node[\labpos=3pt,fill=white]{\pt};
};
\end{tikzpicture}
\captionof{figure}{Graphical Illustration of Dataset with an Arbitrary Caption to Highlight the Problem}
\end{center}
\end{minipage}
\end{figure}

\end{document}

答案1

更新第三个解决方案是使用包作者在评论中提到的calcwidth未记录的选项添加的。caption

两种解决方案

第一个解决方案

如果您需要保留文本其余部分标题的当前宽度设置,则可以\captionsetup在每个命令之前发出一个新命令\captionof。请注意,这并不像听起来那么糟糕

\captionsetup{width=0.8\linewidth}

在每种情况下。关键是线宽的值由当前值决定,minipage因此这给出了0.8当前环境的宽度minipage

示例输出

\documentclass[
11pt
]{scrartcl}

\usepackage{
tikz,
relsize,
amsmath,
booktabs,
tikz
}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}


\usepackage[
labelfont=sf,
hypcap=false,
format=hang,
width=0.8\columnwidth
]{caption}

\usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,
decorations.pathreplacing,
decorations.pathmorphing,
decorations.shapes,
decorations.text,
shapes,
shapes.geometric,
shapes.symbols,
matrix,
patterns,
intersections,
fit}

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\tikzset{
>=latex
}

\begin{document}

\begin{figure}[btc]
\begin{minipage}[c]{0.48\linewidth}
\begin{center}
\captionsetup{width=0.8\linewidth}
\captionof{table}{Dataset for Something  with an Arbitrary Caption to
Highlight the Problem}
\begin{tabular}{lrrrrr}
\toprule
Store & A & B & C & D & E \\
\cmidrule(r{0.125em}){1-1}%
\cmidrule(lr{0.125em}){2-2}%
\cmidrule(lr{0.125em}){3-3}%
\cmidrule(lr{0.125em}){4-4}%
\cmidrule(lr{0.125em}){5-5}%
\cmidrule(l{0.25em}){6-6}%
Input & 0.75 & 1 & 2 & 5 & 5\\
Output & 0.5 & 2 & 4 & 2 & 5\\
\bottomrule
\end{tabular}
\end{center}
\end{minipage}
\hfill
\begin{minipage}[c]{0.48\linewidth}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small]
%
\draw[style=help lines,step=0.5cm] (0,0) grid (6,6);
%
\draw[->,thick] (-0.1,0) -- (6.5,0) node[midway,below=8pt]{Output}; %X-Achse
\draw[->,thick] (0,-0.1) -- (0,6.5) node[above=5pt]{Input}; %Y-Achse
%
\foreach \x in {0,1,...,6} \draw [thick](\x cm,-2pt) -- (\x cm,2pt);
\foreach \y in {0,1,...,6} \draw [thick](-2pt,\y) -- (2pt,\y);
%
\foreach \x in {0,1,...,6} \draw (\x cm, 0 cm) node[anchor=north]{\x} coordinate (x axis);
\foreach \y in {0,1,...,6}  \draw (0 cm, \y cm) node[anchor=east]{\y} coordinate (y axis);
%
\draw
(0,0) coordinate (orig)
(0.75,0.5) coordinate (A)
(1,2) coordinate (B)
(2,4) coordinate (C)
(5,2) coordinate (D)
(5,5) coordinate (E)
;
%
\foreach \pt/\labpos in {A/right,D/below left,E/below}{
  \fill (\pt) circle (2pt) node[\labpos=3pt,fill=white]{\pt};
};
\foreach \pt/\labpos in {B/above left,C/above left}{
  \fill (\pt) circle (3pt) node[\labpos=3pt,fill=white]{\pt};
};
\end{tikzpicture}
\captionsetup{width=0.8\linewidth}
\captionof{figure}{Graphical Illustration of Dataset with an Arbitrary Caption to Highlight the Problem}
\end{center}
\end{minipage}
\end{figure}

\end{document}

第二种解决方案

另一种方法是通过边距大小而不是宽度来指定标题结构,这样您就不需要每次都发出单独的设置命令:

样本保证金规范

\documentclass[
11pt
]{scrartcl}

\usepackage{
tikz,
relsize,
amsmath,
booktabs,
tikz
}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}


\usepackage[
labelfont=sf,
hypcap=false,
format=hang,
margin=1cm,
]{caption}

\usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,
decorations.pathreplacing,
decorations.pathmorphing,
decorations.shapes,
decorations.text,
shapes,
shapes.geometric,
shapes.symbols,
matrix,
patterns,
intersections,
fit}

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\tikzset{
>=latex
}

\begin{document}

\begin{figure}[btc]
\begin{minipage}[c]{0.48\linewidth}
\begin{center}
%\captionsetup{width=0.8\linewidth}
\captionof{table}{Dataset for Something  with an Arbitrary Caption to
Highlight the Problem}
\begin{tabular}{lrrrrr}
\toprule
Store & A & B & C & D & E \\
\cmidrule(r{0.125em}){1-1}%
\cmidrule(lr{0.125em}){2-2}%
\cmidrule(lr{0.125em}){3-3}%
\cmidrule(lr{0.125em}){4-4}%
\cmidrule(lr{0.125em}){5-5}%
\cmidrule(l{0.25em}){6-6}%
Input & 0.75 & 1 & 2 & 5 & 5\\
Output & 0.5 & 2 & 4 & 2 & 5\\
\bottomrule
\end{tabular}
\end{center}
\end{minipage}
\hfill
\begin{minipage}[c]{0.48\linewidth}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small]
%
\draw[style=help lines,step=0.5cm] (0,0) grid (6,6);
%
\draw[->,thick] (-0.1,0) -- (6.5,0) node[midway,below=8pt]{Output}; %X-Achse
\draw[->,thick] (0,-0.1) -- (0,6.5) node[above=5pt]{Input}; %Y-Achse
%
\foreach \x in {0,1,...,6} \draw [thick](\x cm,-2pt) -- (\x cm,2pt);
\foreach \y in {0,1,...,6} \draw [thick](-2pt,\y) -- (2pt,\y);
%
\foreach \x in {0,1,...,6} \draw (\x cm, 0 cm) node[anchor=north]{\x} coordinate (x axis);
\foreach \y in {0,1,...,6}  \draw (0 cm, \y cm) node[anchor=east]{\y} coordinate (y axis);
%
\draw
(0,0) coordinate (orig)
(0.75,0.5) coordinate (A)
(1,2) coordinate (B)
(2,4) coordinate (C)
(5,2) coordinate (D)
(5,5) coordinate (E)
;
%
\foreach \pt/\labpos in {A/right,D/below left,E/below}{
  \fill (\pt) circle (2pt) node[\labpos=3pt,fill=white]{\pt};
};
\foreach \pt/\labpos in {B/above left,C/above left}{
  \fill (\pt) circle (3pt) node[\labpos=3pt,fill=white]{\pt};
};
\end{tikzpicture}
%\captionsetup{width=0.8\linewidth}
\captionof{figure}{Graphical Illustration of Dataset with an Arbitrary Caption to Highlight the Problem}
\end{center}
\end{minipage}
\end{figure}

\end{document}

第三种解决方案

作者 Axel Sommerfeldt 在评论中提到,caption 有一个新的非文档选项,即calcwidth。测试后,它在您的示例中运行良好,至少在 form calcwidth=0.8\linewidthas 包选项中如此。它在每次使用时都会重新计算宽度规范,而不是在文档开头固定计算值。

如果您使用calcwidth=0.8\columnwidth,则必须非常小心地放置切换列数的命令。由于您的示例是单列布局,因此我将坚持使用简单的\linewidth

为了便于说明,我还添加了RaggedRight标题。这允许使用一些连字符,而与之相反,raggedright只会在单词边界处断行。

计算输出示例

\documentclass[
11pt
]{scrartcl}

\usepackage{
tikz,
relsize,
amsmath,
booktabs,
tikz,ragged2e
}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}


\usepackage[
labelfont=sf,
hypcap=false,
format=hang,
margin=1cm,
justification=RaggedRight,
calcwidth=0.8\linewidth
]{caption}

\usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,
decorations.pathreplacing,
decorations.pathmorphing,
decorations.shapes,
decorations.text,
shapes,
shapes.geometric,
shapes.symbols,
matrix,
patterns,
intersections,
fit}

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\tikzset{
>=latex
}

\begin{document}

\begin{figure}[btc]
\begin{minipage}[c]{0.48\linewidth}
\begin{center}
\captionof{table}{Dataset for Something  with an Arbitrary Caption to
Highlight the Problem}
\begin{tabular}{lrrrrr}
\toprule
Store & A & B & C & D & E \\
\cmidrule(r{0.125em}){1-1}%
\cmidrule(lr{0.125em}){2-2}%
\cmidrule(lr{0.125em}){3-3}%
\cmidrule(lr{0.125em}){4-4}%
\cmidrule(lr{0.125em}){5-5}%
\cmidrule(l{0.25em}){6-6}%
Input & 0.75 & 1 & 2 & 5 & 5\\
Output & 0.5 & 2 & 4 & 2 & 5\\
\bottomrule
\end{tabular}
\end{center}
\end{minipage}
\hfill
\begin{minipage}[c]{0.48\linewidth}
\begin{center}
\begin{tikzpicture}[font=\sffamily\small]
%
\draw[style=help lines,step=0.5cm] (0,0) grid (6,6);
%
\draw[->,thick] (-0.1,0) -- (6.5,0) node[midway,below=8pt]{Output}; %X-Achse
\draw[->,thick] (0,-0.1) -- (0,6.5) node[above=5pt]{Input}; %Y-Achse
%
\foreach \x in {0,1,...,6} \draw [thick](\x cm,-2pt) -- (\x cm,2pt);
\foreach \y in {0,1,...,6} \draw [thick](-2pt,\y) -- (2pt,\y);
%
\foreach \x in {0,1,...,6} \draw (\x cm, 0 cm) node[anchor=north]{\x} coordinate (x axis);
\foreach \y in {0,1,...,6}  \draw (0 cm, \y cm) node[anchor=east]{\y} coordinate (y axis);
%
\draw
(0,0) coordinate (orig)
(0.75,0.5) coordinate (A)
(1,2) coordinate (B)
(2,4) coordinate (C)
(5,2) coordinate (D)
(5,5) coordinate (E)
;
%
\foreach \pt/\labpos in {A/right,D/below left,E/below}{
  \fill (\pt) circle (2pt) node[\labpos=3pt,fill=white]{\pt};
};
\foreach \pt/\labpos in {B/above left,C/above left}{
  \fill (\pt) circle (3pt) node[\labpos=3pt,fill=white]{\pt};
};
\end{tikzpicture}
\captionof{figure}{Graphical Illustration of Dataset with an Arbitrary Caption to Highlight the Problem}
\end{center}
\end{minipage}
\end{figure}

\end{document}

相关内容