parbox 后烦人的幽灵柱

parbox 后烦人的幽灵柱

所以我之前问过一个问题关于TeX 宏包中的figures 和内部框。我得到了一个有效的 MWE,但在我的完整文档中实现它让我意识到与该解决方案相关的另一个问题。tikzpicturesinsbox

parbox伯纳德告诉我,如果我想在图表下方添加标题,可以使用这个标题,但出于某种原因,这个标题parbox会按照我指定的宽度在文档的其余部分中描绘出一整列。

添加封闭组会删除后面段落的列,但不会删除包裹在框周围的段落。

最奇怪的是,删除上一章关于复数的图表可以解决问题。这个图表对文档后面的段落有什么影响?

有人知道发生了什么事吗?

平均能量损失

\documentclass[a5paper,12pt,twoside,openany]{memoir}
\usepackage[a5paper]{geometry}
\usepackage{tikz}
\usepackage{caption}
\usepackage[latin]{babel}
\usepackage{lipsum}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preamble brought into the MWE:

\usepackage{tocloft}
\usepackage{hyperref}
\usepackage{emptypage}
\usepackage[inline]{enumitem}
\usepackage[export]{adjustbox}
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage[usenames,dvipnames,table]{xcolor}

\usepackage{bm,amsmath,amssymb,amsthm,gensymb,esdiff,siunitx}

%---------------------------------

% Universal command to recognise environments:

\makeatletter

\def\ifenv#1{
   \def\@tempa{#1}%
   \ifx\@tempa\@currenvir
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
   \fi
}

\makeatother

\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\newenvcommand}{ m m } % #1 = env name, #2 = command name
  {
   \cs_if_exist:cF { g_envc_#1_list_tl } { \tl_new:c { g_envc_#1_list_tl } }
   \tl_gput_right:cn { g_envc_#1_list_tl } { #2 }
   \exp_after:wN \newcommand \cs:w envc_#1_\cs_to_str:N #2 \cs_end:
   % { Removing this line will cause Overleaf to make trouble }
  } 
\NewDocumentCommand{\checkenvcommands}{ }
  {
   \cs_if_exist:cT { g_envc_\use:c {@currenvir} _list_tl }
     {
      \tl_map_inline:cn { g_envc_\use:c {@currenvir} _list_tl }
        { \cs_set_eq:Nc ##1 { envc_\use:c {@currenvir} _\cs_to_str:N ##1 } }
     }
  }
\ExplSyntaxOff

%---------------------------------

% Boxes:

\usepackage{empheq}
\usepackage[many]{tcolorbox}

\tcbset{enhanced,boxrule=0.8pt,bottomrule=1.6pt,arc=0pt,auto outer arc,lifted shadow={1mm}{-1mm}{2mm}{0.1mm}{gray!60}}
\newtcbox{\eqbox}[3][]{nobeforeafter,math upper,colback=#2,colframe=#3,#1}
\newtcbox{\ndbox}[3][]{nobeforeafter,math upper,colback=#2,colframe=#3,#1}

\usepackage{tikz}
\usetikzlibrary{calc}

\tikzset{highlight/.style args={#1}{fill=#1,rounded corners=1.6pt,inner xsep=1ex,minimum height=1.5em},
%copy shadow={shadow xshift=0pt,shadow yshift=-0.4pt},
mylight/.style={highlight={red!30!yellow!40}{black!30!red!30!yellow}}}

%---------------------------------
\newenvcommand{tcolorbox}{\ul}[1]{%
  \uline{\phantom{#1}}%
  \llap{\contour{shadecolor}{#1}}%
}
%---------------------------------

% Preamble over.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\usetikzlibrary{backgrounds}
\tikzset{font={\fontsize{10pt}{11pt}\selectfont}}

\input{insbox}

\begin{document}

\section{Complex Numbers}

\begin{figure}[htp]
    \centering
    \begin{tikzpicture}[x=4cm,y=4cm]

        \draw [->, thick] (-1.25,0) coordinate (Xin)
                       -- ( 0.00,0)
                       -- ( 0.50,0) node[midway,highlight=white] {cos}
                       -- ( 1.25,0) coordinate (Xout);
        \draw [->, thick] (0,-1.20) coordinate (Yin)
                       -- (0, 0.00)
                       -- (0, 0.50) node[midway,sloped,highlight=white,yshift=2pt] {sin}
                       -- (0, 1.20) coordinate (Yout);

        \draw [ultra thick] circle (1);

        \foreach \t in {30,45,60,120,135,150}
        {
            \coordinate   (d\t) at (\t:1);
            \coordinate (c2d\t) at (\t:2);
        }
        \foreach \t in {30,45,60,120,135,150}
        {
            \coordinate   (n\t) at (360-\t:1);
            \coordinate (c2n\t) at (360-\t:2);
        }

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % 
        % Lables: [Degrees]

        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=1.1em,minimum width=3em] {$30\degree$} (d30);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=1.1em,minimum width=3em] {$45\degree$} (d45);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=1.1em,minimum width=3em] {$60\degree$} (d60);

        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=1.1em,minimum width=3em] {-$30\degree$} (n30);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=1.1em,minimum width=3em] {-$45\degree$} (n45);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=1.1em,minimum width=3em] {-$60\degree$} (n60);

        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=-1.1em,minimum width=3em] {$120\degree$} (d120);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=-1.1em,minimum width=3em] {$135\degree$} (d135);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=-1.1em,minimum width=3em] {$150\degree$} (d150);

        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=-1.1em,minimum width=3em] {-$120\degree$} (n120);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=-1.1em,minimum width=3em] {-$135\degree$} (n135);
        \draw [dashed, thick] (0,0) -- node[midway,sloped,highlight=white,xshift=-1.1em,minimum width=3em] {-$150\degree$} (n150);

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % 
        % Lables: [Tangent values]

        \coordinate (t30) at (intersection of 1,0--c2d60 and c2d30--d30);

        \draw [thick, dashed] (c2d60) -- (d60);
        \draw [thick, dashed]  (1,1)  -- (d45);
        \draw [thick, dashed]  (t30)  -- (d30);

        \draw [thick, dashed]
                      (c2d60) node[xshift=1.1em,yshift=-.1em] {$\frac{\sqrt{3}}{1}$}
                   -- (1,1)   node[xshift=1.1em,yshift=.1em] {$\frac{1}{1}$}
                   -- (t30)   node[xshift=1.1em,yshift=.3em] {$\frac{1}{\sqrt{3}}$}
                   -- (1,0);1

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % 
        % Lables: [Radians]

        \node [highlight=white] at ($(1,0)+(1.1em,1.1em)$) {$0$};
        \node [highlight=white] at ($(d30)+(1.1em,1.1em)$) {$\frac{\pi}{6}$};
        \node [highlight=white] at ($(d45)+(1.1em,1.1em)$) {$\frac{\pi}{4}$};
        \node [highlight=white] at ($(d60)+(1.1em,1.1em)$) {$\frac{\pi}{3}$};
        \node [highlight=white] at ($(0,1)+(1.1em,1.1em)$) {$\frac{\pi}{2}$};
        \node [highlight=white] at ($(d120)+(-1.1em,1.1em)$) {$\frac{2\pi}{3}$};
        \node [highlight=white] at ($(d135)+(-1.1em,1.1em)$) {$\frac{3\pi}{4}$};
        \node [highlight=white] at ($(d150)+(-1.1em,1.1em)$) {$\frac{5\pi}{6}$};
        \node [highlight=white] at ($(-1,0)+(-1.1em,1.1em)$) {$\pi$};
        \node [highlight=white] at ($(n30)+(1.1em,-1.1em)$) {-$\frac{\pi}{6}$};
        \node [highlight=white] at ($(n45)+(1.1em,-1.1em)$) {-$\frac{\pi}{4}$};
        \node [highlight=white] at ($(n60)+(1.1em,-1.1em)$) {-$\frac{\pi}{3}$};
        \node [highlight=white] at ($(0,-1)+(1.1em,-1.1em)$){-$\frac{\pi}{2}$};
        \node [highlight=white] at ($(n120)+(-1.1em,-1.1em)$) {-$\frac{2\pi}{3}$};
        \node [highlight=white] at ($(n135)+(-1.1em,-1.1em)$) {-$\frac{3\pi}{4}$};
        \node [highlight=white] at ($(n150)+(-1.1em,-1.1em)$) {-$\frac{5\pi}{6}$};

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % 
        % 

        \coordinate (s30) at (intersection of Yin--Yout and d30--d150);
        \coordinate (s45) at (intersection of Yin--Yout and d45--d135);
        \coordinate (s60) at (intersection of Yin--Yout and d60--d120);

        \coordinate (c60) at (intersection of Xin--Xout and d60--n60);
        \coordinate (c45) at (intersection of Xin--Xout and d45--n45);
        \coordinate (c30) at (intersection of Xin--Xout and d30--n30);

        \coordinate (c120) at (intersection of Xin--Xout and d120--n120);
        \coordinate (c135) at (intersection of Xin--Xout and d135--n135);
        \coordinate (c150) at (intersection of Xin--Xout and d150--n150);

        \coordinate (sn30) at (intersection of Yin--Yout and n30--n150);
        \coordinate (sn45) at (intersection of Yin--Yout and n45--n135);
        \coordinate (sn60) at (intersection of Yin--Yout and n60--n120);

        \fill ($(s30)-(2pt,.4pt)$) rectangle ($(s30)+(2pt,.4pt)$) node[left,xshift=-1ex] {$\frac{\sqrt{1}}{2}$};
        \fill ($(s45)-(2pt,.4pt)$) rectangle ($(s45)+(2pt,.4pt)$) node[left,xshift=-1ex] {$\frac{\sqrt{2}}{2}$};
        \fill ($(s60)-(2pt,.4pt)$) rectangle ($(s60)+(2pt,.4pt)$) node[left,xshift=-1ex] {$\frac{\sqrt{3}}{2}$};
        \fill ($(c60)-(.4pt,2pt)$) rectangle ($(c60)+(.4pt,2pt)$) node[below,yshift=-1ex]{$\frac{\sqrt{1}}{2}$};
        \fill ($(c45)-(.4pt,2pt)$) rectangle ($(c45)+(.4pt,2pt)$) node[below,yshift=-1ex]{$\frac{\sqrt{2}}{2}$};
        \fill ($(c30)-(.4pt,2pt)$) rectangle ($(c30)+(.4pt,2pt)$) node[below,yshift=-1ex]{$\frac{\sqrt{3}}{2}$};

        \fill ($(sn30)-(2pt,.4pt)$) rectangle ($(sn30)+(2pt,.4pt)$) node[left,xshift=-1ex] {-$\frac{\sqrt{1}}{2}$};
        \fill ($(sn45)-(2pt,.4pt)$) rectangle ($(sn45)+(2pt,.4pt)$) node[left,xshift=-1ex] {-$\frac{\sqrt{2}}{2}$};
        \fill ($(sn60)-(2pt,.4pt)$) rectangle ($(sn60)+(2pt,.4pt)$) node[left,xshift=-1ex] {-$\frac{\sqrt{3}}{2}$};
        \fill ($(c150)-(.4pt,2pt)$) rectangle ($(c150)+(.4pt,2pt)$) node[below,yshift=-1ex]{-$\frac{\sqrt{1}}{2}$};
        \fill ($(c135)-(.4pt,2pt)$) rectangle ($(c135)+(.4pt,2pt)$) node[below,yshift=-1ex]{-$\frac{\sqrt{2}}{2}$};
        \fill ($(c120)-(.4pt,2pt)$) rectangle ($(c120)+(.4pt,2pt)$) node[below,yshift=-1ex]{-$\frac{\sqrt{3}}{2}$};
    \end{tikzpicture}
  % \caption{Caption}
    \label{fig:my_label}
\end{figure}

\section{Differential Equations}

This is a test paragraph above the box.

{%---------- begins enclosing group
\InsertBoxL{0}{%
\parbox{5cm}
{   \begin{tikzpicture}[x=.25in,y=.25in]
        \draw [<-, thick] (0, 4.2) coordinate (Yin) node [above] {$y$}
                       -- (0, 0.0)
                       -- (0,-1.2) coordinate (Yout);
        \draw [->, thick] (-1.5,0) coordinate (Xin)
                       -- ( 0.0,0)
                       -- ( 4.5,0) coordinate (Xout) node [right] {$x$};
        \draw [thick] (2.8, 0.9) -- (1.8, 0.9) node [midway,below] {$\Delta x$};
        \draw [thick] (2.8, 0.9) -- (2.8, 1.4) node [midway,right] {$\Delta y$};
        \draw [domain=-1:4,variable=\x,red,thick] plot({\x},{(\x)/2});
    \end{tikzpicture}
    \captionsetup{font=compact}
    \captionof{figure}{Linear function}
    \label{fig:linear}
}}[4]
\noindent\lipsum[1]
}%---------- ends enclosing group

\noindent\lipsum[1]

\noindent\lipsum[1]

\end{document}

答案1

问题似乎出在上一节的浮动图形上。如果你在上一节的末尾添加 \clearpage,就没有问题了,你甚至可以删除括号。

无关:您不必使用[usenames]中的选项xcolor,因为它已经是默认选项好几年了。另外:hyperref作为最后一个包加载(极少数例外,最值得注意的是cleveref应该加载 超链接)。

............

\clearpage
\section{Differential Equations}

This is a test paragraph above the box.

\InsertBoxL{0}{%
\parbox{5cm}
{ \begin{tikzpicture}[x=.25in,y=.25in]
        \draw [<-, thick] (0, 4.2) coordinate (Yin) node [above] {$y$}
                       -- (0, 0.0)
                       -- (0,-1.2) coordinate (Yout);
        \draw [->, thick] (-1.5,0) coordinate (Xin)
                       -- ( 0.0,0)
                       -- ( 4.5,0) coordinate (Xout) node [right] {$x$};
        \draw [thick] (2.8, 0.9) -- (1.8, 0.9) node [midway,below] {$\Delta x$};
        \draw [thick] (2.8, 0.9) -- (2.8, 1.4) node [midway,right] {$\Delta y$};
        \draw [domain=-1:4,variable=\x,red,thick] plot({\x},{(\x)/2});
    \end{tikzpicture}
    \captionof{figure}{Linear function}
    \label{fig:linear}
}}[4]

\noindent\lipsum[1]

\noindent\lipsum[1]

\noindent\lipsum[1]

在此处输入图片描述

答案2

我猜你想要的wrapfig不只是一个普通的 TeX hack,比如insbox.tex

\documentclass[a5paper,12pt,twoside,openany]{memoir}

\usepackage[a5paper]{geometry}
\usepackage{caption}
\usepackage[latin]{babel}
\usepackage{wrapfig}

\usepackage{tikz}
%\usetikzlibrary{calc}
%\usetikzlibrary{backgrounds}

\usepackage{lipsum} % for mock text

\begin{document}

\section{Differential Equations}

This is a test paragraph above the box.

\begin{wrapfigure}{l}{5cm}
 \begin{tikzpicture}[x=.25in,y=.25in]
        \draw [<-, thick] (0, 4.2) coordinate (Yin) node [above] {$y$}
                       -- (0, 0.0)
                       -- (0,-1.2) coordinate (Yout);
        \draw [->, thick] (-1.5,0) coordinate (Xin)
                       -- ( 0.0,0)
                       -- ( 4.5,0) coordinate (Xout) node [right] {$x$};
        \draw [thick] (2.8, 0.9) -- (1.8, 0.9) node [midway,below] {$\Delta x$};
        \draw [thick] (2.8, 0.9) -- (2.8, 1.4) node [midway,right] {$\Delta y$};
        \draw [domain=-1:4,variable=\x,red,thick] plot({\x},{(\x)/2});
    \end{tikzpicture}
    \caption{Linear function}
    \label{fig:linear}
\end{wrapfigure}

\lipsum[1-3]

\end{document}

在此处输入图片描述

相关内容