浮动(数字......)不尊重调整宽度的宽度

浮动(数字......)不尊重调整宽度的宽度

当我在使用 的环境中间使用浮点数时adjustwidth,标题会占用整个空间,而不是仅占用调整宽度允许的空间。问题是我想在使用 获得的边距中绘制线条adjustwidth,并且线条与内容重叠:

在此处输入图片描述

有没有办法确保我的字幕能够正确显示(如果您有适用于浮点数的更好的解决方案,我可以摆脱 adjustwidth )?

平均能量损失

\documentclass[options]{memoir}

\RequirePackage{tikz}
\usetikzlibrary{calc,tikzmark}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{thmtools} %% Improves existing theorem packages (like amsthm) and provides declaretheorem
\theoremstyle{plain} % Style, see http://www.ams.org/arc/tex/amscls/amsthdoc.pdf p. 8 for recommanded styles
\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\begin{document}
\lipsum[1][1-3]

\begin{adjustwidth}{2cm}{0cm}
  \advance\textwidth-2cm% Hum... Is it safe to do that?
  \advance\linewidth-2cm
  \lipsum[2][1-3]

  \noindent\rule{\textwidth}{1mm}
  \begin{figure}[h]
    \centering
    \noindent\rule{\textwidth}{2mm}\\
    See I don't care about adjustwidth
    \caption{\lipsum[3][1-3]}
    \label{fig:fds}
  \end{figure}
  \lipsum[2][1-3]
\end{adjustwidth}


\end{document}

对于标题,我发现了一个有趣的技巧:\captionsetup。我不确定这是否是最好的解决方案……但确实有效。但不幸的是,它并不适用于所有浮点数。例如,它不适用于使用环境定义的浮点数float

如果您有更好的解决方案(可能适用于更多类型的浮点数),请告诉我。另外,如果您知道如何将图像居中,我会很感兴趣。

在此处输入图片描述

\documentclass[options]{memoir}

\RequirePackage{tikz}
\usetikzlibrary{calc,tikzmark}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{thmtools} %% Improves existing theorem packages (like amsthm) and provides declaretheorem
\theoremstyle{plain} % Style, see http://www.ams.org/arc/tex/amscls/amsthdoc.pdf p. 8 for recommanded styles
\declaretheorem[name=Theorem,numberwithin=section]{theorem}
\usepackage{caption}
%% Hyperref should be loaded before cryptocode! Otherwise, errors with labels of lines for example.
%%% Cryptocode
\usepackage [
  lambda,
  advantage,
  operators,
  sets,
  adversary,
  landau,
  probability,
  notions,
  logic,
  ff,
  mm,
  primitives,
  events,
  complexity,
  asymptotics,
  keys
  ] {cryptocode}
\usepackage{float}
\floatstyle{ruled} % Defines the "rule" style for next environments defined using newfloat.
\newfloat{protocol}{htb!}{protocol}
\floatname{protocol}{Protocol}

\begin{document}
\lipsum[1][1-3]

\begin{adjustwidth}{2cm}{0cm}
  \advance\textwidth-2cm% Hum... Is it safe to do that?
  \advance\linewidth-2cm%
  \captionsetup{width=\linewidth} % The width seems actually smaller than linewidth, but it does the trick.
  \lipsum[2][1-3]

  \noindent\rule{\textwidth}{1mm}
  \begin{figure}[h]
    \centering
    \noindent\rule{\textwidth}{2mm}\\
    See I don't care about adjustwidth
    \caption{\lipsum[3][1-3]}
    \label{fig:fds}
  \end{figure}
  \lipsum[2][1-3]
  \begin{protocol}
    \caption{My caption}
    \lipsum[1][1]
  \end{protocol}

  \lipsum[1][1-2]
\end{adjustwidth}


\end{document}

编辑

通过添加,\advance\columnwidth-2cm我还设法使用该库更改插入的浮点数的大小float...不幸的是,它仍然不完美,因为浮点数被向左刷新,所以重叠是相同的,并且图片现在甚至更不居中^^

在此处输入图片描述

编辑

我尝试应用 John 的建议,在浮动元素内插入 adjustwidth。对于图片,我成功了一点(标题仍然表现不正常,要么太大,要么\captionsetup{width=1\linewidth}太小),但对于其他浮动元素,我却失败了:

在此处输入图片描述

\documentclass[options]{memoir}

\RequirePackage{tikz}
\usetikzlibrary{calc,tikzmark}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{thmtools} %% Improves existing theorem packages (like amsthm) and provides declaretheorem
\theoremstyle{plain} % Style, see http://www.ams.org/arc/tex/amscls/amsthdoc.pdf p. 8 for recommanded styles
\declaretheorem[name=Theorem,numberwithin=section]{theorem}
\usepackage{caption}
%% Hyperref should be loaded before cryptocode! Otherwise, errors with labels of lines for example.
%%% Cryptocode
\usepackage [
  lambda,
  advantage,
  operators,
  sets,
  adversary,
  landau,
  probability,
  notions,
  logic,
  ff,
  mm,
  primitives,
  events,
  complexity,
  asymptotics,
  keys
  ] {cryptocode}
\usepackage{float}
\floatstyle{ruled} % Defines the "rule" style for next environments defined using newfloat.
\newfloat{protocol}{htb!}{protocol}
\floatname{protocol}{Protocol}

\begin{document}
\lipsum[1][1-3]

\begin{adjustwidth}{2cm}{0cm}
  \advance\textwidth-2cm% Hum... Is it safe to do that?
  \advance\linewidth-2cm%
  \captionsetup{width=1\linewidth} % The width seems actually smaller than linewidth, but it does the trick.
  \lipsum[2][1-3]

  \noindent\rule{\textwidth}{1mm}
  \begin{figure}[h]
    \begin{adjustwidth}{2cm}{0cm}
      %\advance\textwidth-2cm% Hum... Is it safe to do that?
      %\advance\linewidth-2cm%
      %\captionsetup{width=\linewidth} % The width seems actually smaller than linewidth, but it does the trick.
      \centering
      \noindent\rule{\textwidth}{2mm}\\
      See I don't care about adjustwidth
      \caption{\lipsum[3][1-3]}
      \label{fig:fds}
    \end{adjustwidth}
  \end{figure}
  \lipsum[2][1-3]
  \begin{protocol}
    \begin{adjustwidth}{2cm}{0cm}
      \caption{My caption}
      \lipsum[1][1]
    \end{adjustwidth}
  \end{protocol}

  \lipsum[1][1-2]
\end{adjustwidth}


\end{document}

更新

感谢 David 在 minipages 上的评论,我尝试在图形中创建一个……事实上,它基本上解决了图片的问题(现在我需要自动应用它),如果需要,它实际上可以在新页面上浮动。我仍然需要找到一种方法将所有图形环境修补到我的调整宽度中,但它正在实现。但是,我不确定如何将它应用于其他类型的浮动,如果我在规则环境中这样做,补丁不会应用于标题。

在此处输入图片描述

\documentclass[options]{memoir}

\RequirePackage{tikz}
\usetikzlibrary{calc,tikzmark}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{thmtools} %% Improves existing theorem packages (like amsthm) and provides declaretheorem
\theoremstyle{plain} % Style, see http://www.ams.org/arc/tex/amscls/amsthdoc.pdf p. 8 for recommanded styles
\declaretheorem[name=Theorem,numberwithin=section]{theorem}
\usepackage{caption}
\usepackage{float}
\floatstyle{ruled} % Defines the "rule" style for next environments defined using newfloat.
\newfloat{protocol}{htb!}{protocol}
\floatname{protocol}{Protocol}

\begin{document}
\lipsum[1][1-3]

\begin{adjustwidth}{2cm}{0cm}
  \advance\textwidth-2cm% Hum... Is it safe to do that?
  %\advance\columnwidth-2cm% Hum... it's breaking images
  %\captionsetup{width=1\linewidth} % The width seems actually smaller than linewidth, but it does the trick.
  \lipsum[2][1-3]. Checking that linewidth and textwidth are appropriately configured

  \noindent\rule{\linewidth}{1mm}

  \noindent\rule{\textwidth}{1mm}

  \lipsum[2][1-3]

  \begin{figure}[htbp]
    \begin{adjustwidth}{2cm}{0cm}
      \noindent\begin{minipage}{1.0\linewidth}
        \includegraphics[width=\textwidth]{example-image-a}
        \caption{I am a true float, with the appropriate margin!! Now I need to patch all figure environments automatically.}
      \end{minipage}
    \end{adjustwidth}
  \end{figure}

  Unfortunately, floats created with the float package are still not patched.
  \begin{protocol}
    \begin{adjustwidth}{2cm}{0cm}
      \noindent\begin{minipage}{1.0\linewidth}
      \caption{Non patched float}
      The adjustwidth is applied to the content of the float but not the the surounding. I need to find a way to apply this patch directly around the float.
      \end{minipage}
    \end{adjustwidth}
  \end{protocol}

  \lipsum[1][1-2]
\end{adjustwidth}


\end{document}

相关内容