\usepackage{sectsty}我相信这些与该包相关。

\usepackage{sectsty}我相信这些与该包相关。

更新故障所在...请参考下面的代码。我添加了一个包和一个定义

\documentclass[twocolumn]{book}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{pgfplots}
\usepackage{titletoc} 
\usepackage{booktabs} %%<-- added NEW NEW ENWE NEW
\newcommand{\head}[1]{\textnormal{\textbf{#1}}} %%%%% <--- added NEW NEW NEW NEW
\usepackage{blindtext}% dummy text 
\usepackage{geometry,xcolor,amssymb,amsmath,graphicx}% 
\usepackage{sectsty} 
\sectionfont{\sectionrule{1.4ex}{2pt}{-.6ex}{2pt}%
{\small \sffamily\centering\vspace{-2.65ex}\MakeUppercase}}
%\allsectionsfont{\raggedright\ulemheading{\uuline}}
\subsectionfont{\sffamily\MakeUppercase}
\vspace{-5ex}
\usepackage[colorlinks=true,urlcolor=blue]{hyperref}% dummy text
\contentsmargin{0cm}
% End of preamble ===========================
\begin{document}
\chapter{hello3}
\section{hello blinder}
\subsection{nothing}
-
\subsection{nothing}
-
\subsection{sample}
{\small
\begin{table}[H]
\caption*{{\small $\blacksquare$: Man.\\ $\square$: Woman }}
{\small
\begin{tabular}{ll}
\toprule[1.5pt]
\multicolumn{2}{c}{\head{next generation}}\\
\head{{\footnotesize byye}} & \head{{\footnotesize hello}}\\
\midrule
\hfill$\blacksquare$ &\hfill$\blacksquare$ \\\hfill$\square$ &\hfill$\square$ \\
\bottomrule[1.5pt]
\end{tabular}
}
\end{table}
}
{\tiny
\begin{table}[H]
{\small
\begin{tabular}{ll}
\toprule[1.5pt]
\multicolumn{2}{c}{\head{next generation}}\\
\head{{\footnotesize next  1}} & \head{{\footnotesize next 2}}\\
\midrule
\hfill$\blacksquare$ &\hfill$\blacksquare$\\\hfill$\square$ &\hfill$\square$\\
\bottomrule[1.5pt]
\end{tabular}
}
\end{table}
}
\subsection{sample2}
\centering
\textbf{sample3}
asdasdasd
\textbf{sample2}
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={zzz, yyy, xxx },
y tick label style={/pgf/number format/.cd,%
scaled y ticks = false,
set thousands separator={},
fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.23) };
\addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.51) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.26)  };
\end{axis}
\end{tikzpicture}
\subsection{FACILITIES}
-
\subsection{sample}
\blindtext[2]
\section{New Section}
\subsection{clown4}
\blindtext[4]
\subsection{clown3}
\blindtext[4]
\subsection{clown2}
{\small
\begin{table}[H]
\caption*{{\small $\blacksquare$: Man.\\ $\square$: Woman. }}
{\small
\begin{tabular}{ll}
\toprule[1.5pt]
\multicolumn{2}{c}{\head{next generation}}\\
\head{{\footnotesize next generation}} & \head{{\footnotesize next generation}}\\
\midrule
En\hfill$\blacksquare$ &Ena\hfill$\blacksquare$ \\Chi\hfill$\square$           
&Chiegua\hfill$\square$ \\Maics\hfill$\square$ &Macs\hfill$\square$ 
\\Science\hfill$\square$ &Lidie\hfill$\square$ \\Compuer\hfill$\square$ 
&Phs\hfill$\square$ \\Chnesor\hfill$\square$ &Chery\hfill$\square$ 
\\Hisy\hfill$\square$ &Bigy\hfill$\square$    \\Gehy\hfill$\square$ 
&Infoationan\hfill$\square$ \\Eccau\hfill$\square$ &Bess\hfill$\square$ 
\\Mic\hfill$\square$ &Accond\hfill$\square$ \\Physica\hfill$\square$ 
&Ecmics\hfill$\square$ \\VisualArts\hfill$\square$ &Chior\hfill$\square$ 
\\Ded\hfill$\square$ &Hiy\hfill$\square$ \\Hoonomics\hfill$\square$ 
&Geaphy\hfill$\square$ \\Putua\hfill$\square$ &Touros\hfill$\square$ 
\\Lie\hfill$\square$ &Viss\hfill$\square$   \\&Desppl\hfill$\square$ 
\\&Phyduca\hfill$\square$ \\&Schr\hfill$\square$ \\
\bottomrule[1.5pt]
\end{tabular}
}
\end{table}
}
{\tiny
\begin{table}[H]
{\small
\begin{tabular}{ll}
\toprule[1.5pt]
\multicolumn{2}{c}{\head{2013/2014}}\\
\head{{\footnotesize S1-S3}} & \head{{\footnotesize S4-S6}}\\
\midrule
Brownie\hfill$\blacksquare$ &Brownie \hfill$\blacksquare$\\Cheap\hfill$\square$ 
&Cheap\hfill$\square$\\womanizer\hfill$\square$ &womanizer 
\hfill$\square$\\Scce\hfill$\square$ &eie\hfill$\square$\\Comr\hfill$\square$ 
&Phcs\hfill$\square$\\Cheap\hfill$\square$ &hy\hfill$\square$\\Hiy\hfill$\square$ 
&Bgy\hfill$\square$\\Gphy\hfill$\square$ &form\hfill$\square$\\Ecu\hfill$\square$ 
&Bss\hfill$\square$\\Mic\hfill$\square$ &Accand\hfill$\square$\\Pca\hfill$\square$ 
&Eccs\hfill$\square$\\Vts\hfill$\square$ &Cistor\hfill$\square$\\Ded\hfill$\square$ 
&Hory\hfill$\square$\\Hcs\hfill$\square$ &aphy\hfill$\square$\\hua\hfill$\square$ 
&Tos\hfill$\square$\\Liie\hfill$\square$   
&Vts\hfill$\square$\\&Dppl\hfill$\square$\\&Pca\hfill$\square$\\&SdAr\hfill$\square$\\
\bottomrule[1.5pt]
\end{tabular}
}
\end{table}
}
\subsection{Spring term}
\centering
\textbf{helloo clown}
asdasdasd
\textbf{hello baffoon}
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={$0-4$ years, $5-9$ years, $>10$ years },
y tick label style={/pgf/number format/.cd,%
scaled y ticks = false,
set thousands separator={},
fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.42) };
\addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.28) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.3)  };
\end{axis}
\end{tikzpicture}
\subsection{something2}
\blindtext[3]
\subsection{something 4}
\blindtext[4]
\end{document}

因此,我修改了下面答案中慷慨而有见地的解决方案,但当我包含其他信息时,它似乎崩溃了......例如......我相信这是我在原始解决方案中\hello macro使用该包的原因之一。extraplaceins

\documentclass[twocolumn]{book}

\usepackage[T1]{fontenc}

\usepackage{caption}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{pgfplots}

\usepackage{titletoc}
\usepackage{blindtext}% dummy text
\usepackage{geometry,xcolor,amssymb,amsmath,graphicx}%    

\usepackage{sectsty} 
\sectionfont{\sectionrule{1.4ex}{2pt}{-.6ex}{2pt}%
{\small \sffamily\centering\vspace{-2.65ex}\MakeUppercase}}
%\allsectionsfont{\raggedright\ulemheading{\uuline}}
\subsectionfont{\sffamily\MakeUppercase}
\newcommand\firstoftwo[2]{#1}
\newcommand\secondoftwo[2]{#2}
\newcommand\hello[9]{%
{\small \sffamily 
\firstoftwo#1\hfill\\% Address
\textbf{\Large Hello} \firstoftwo#2~~$\circ$~~%
\textbf{\Large Hello} \secondoftwo#2\\ 
\textbf{\Large Kitty} \firstoftwo#3 \hfill\\  
\textbf{\Large Pitty} \url{\firstoftwo#5}\hfill\\
\textbf{Smoothness} \firstoftwo#8~~$\circ$~~% 
\textbf{Classification} \firstoftwo#4\\
\textbf{Car Sales} \firstoftwo#9~~$\circ$~~%
\textbf{Micro Sales} \secondoftwo#5\\
\textbf{Ornamentation year} \secondoftwo#9~~$\circ$~~%
\textbf{Gesticulation cancer} \secondoftwo#7\\
\textbf{unknown parody} \secondoftwo#8~~$\circ$~~\\
\textbf{annoying} \secondoftwo#4\\ 
\textbf{as hell} \firstoftwo#6~~\textemdash~~%
\secondoftwo#6}
\begin{quoting}
\footnotesize\Fontskrivan%\calligra ... what you want
\firstoftwo#7
\end{quoting}
\begin{minipage}[c]{\linewidth}
\color{gray}
\offinterlineskip
\rule[0ex]{\linewidth}{.2ex}\vspace{.5mm}
\rule[0ex]{\linewidth}{.4ex}
\end{minipage}
\vspace{-5ex}
}


\begin{document}

\chapter{Hello world}
\blindtext[2]
\section{Hello section title}
\hello
{{ 123123123123132123213}}%
{{123123213}{123123123}}%
{{1233213123123}}%
{{123123123}{asdasdasddasd}}%
{{asdasdasda}{asdadsad}}%
{{asdadasd}{adsadsad}}%
{{adsasdad}{asdadsasd}}
{{asdasdadasdads}}
{{asdasdadsad}{asdasdasd}}




\blindtext[2]
\subsection{some tables and figures here}
\blindtext[1]
\subsection{testing}
\blindtext[2]
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[%
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={$0-4$ years, $5-9$ years, $>10$ years },
y tick label style={/pgf/number format/.cd,%
    scaled y ticks = false,
    set thousands separator={},
    fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.23) };
\addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.51) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.26)  };
\end{axis}
\end{tikzpicture}


\subsection{hello}

\section{section title here}
\blindtext[1]
\subsection{something}
\blindtext[1]
\subsection{something else}
\blindtext[2]
\subsection{another subsection}
\blindtext[1]
\subsection{here is a subsection}
\blindtext[1]

\begin{figure}
\centering
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={$0-4$ years, $5-9$ years, $>10$ years },
y tick label style={/pgf/number format/.cd,%
  scaled y ticks = false,
  set thousands separator={},
  fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.42) };
\addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.28) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.3)  };

\end{axis}
\end{tikzpicture}
\end{figure}


\end{document}







\documentclass[twocolumn]{book}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{marvosym}
\usepackage{calligra}
\usepackage{aurical}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{epigraph}
\usepackage{titletoc}
\usepackage{lipsum}% dummy text
\usepackage{geometry,xcolor,amssymb,amsmath,graphicx}% 
\usepackage[colorlinks=true,urlcolor=blue]{hyperref}% dummy text
\usepackage{quoting}
\quotingsetup{vskip=5pt}
\usepackage{PTSansNarrow} 
\usepackage{booktabs}
\newcommand{\head}[1]{\textnormal{\textbf{#1}}}
\usepackage{pgfplots}
\usepackage{float}
\usepackage[section,subsection,subsubsection]{extraplaceins}


\renewcommand\epigraphflush{flushright}
\renewcommand\epigraphsize{\normalsize}
\setlength\epigraphwidth{0.7\textwidth}






%------------------------------------------
\contentsmargin{0cm}
%------------------------------------------


\usepackage{sectsty} 
\sectionfont{\sectionrule{1.4ex}{2pt}{-.6ex}{2pt}%
{\small \sffamily\centering\vspace{-2.65ex}\MakeUppercase}}
%\allsectionsfont{\raggedright\ulemheading{\uuline}}
\subsectionfont{\sffamily\MakeUppercase}
\vspace{-5ex}




% End of preamble ===========================

\begin{document}
\chapter{Hellow world}
\section{Hello section title}
\subsection{some tables and figures here}
\subsection{testing}
\centering
\textbf{something else}
\textbf{some diagram}
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={$0-4$ years, $5-9$ years, $>10$ years },
y tick label style={/pgf/number format/.cd,%
      scaled y ticks = false,
      set thousands separator={},
      fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.23) };
 \addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.51) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.26)  };

\end{axis}
\end{tikzpicture}


\subsection{hello}
-
\section{section title here}
\subsection{something}
something
\subsection{something else}
\subsection{another subsection}
\subsection{here is a subsection}
\centering
\textbf{Some Tikzpicture}
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={$0-4$ years, $5-9$ years, $>10$ years },
y tick label style={/pgf/number format/.cd,%
      scaled y ticks = false,
      set thousands separator={},
      fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.42) };
\addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.28) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.3)  };

\end{axis}
\end{tikzpicture}



\end{document}

更新:

正如 Mico 正确指出的那样,我没有提供问题的完整背景。我使用的是以下环境:

\documentclass[twocolumn]{book}

以及相关希望相关信息如下

\contentsmargin{0cm}

\titleformat{\part}[display]
{\normalfont\huge\bfseries}{\thepart}{20pt}{\Huge}

\titlecontents{part}[0pc]
{
\protect\addvspace{13pt}%
\begin{tikzpicture}%
\draw[help lines,step=.4cm,color=blue] (0,0) grid (2.4,1.2);%
\pgftext[left,x=.1cm,y=.6cm]{\Large\scshape\partname};%
\fill[fill=white,draw=blue] (1.8,.6) circle (0.4cm);%
\node at(1.8cm,.6cm) {I};%
\end{tikzpicture}\\\color{blue}\large\scshape\bfseries
\thepart}%

{}

{l}

{$\;$\titlerule$\;$\large\bfseries\thecontentspage}%



\usepackage{sectsty}

\sectionfont{\sectionrule{1.4ex}{2pt}{-.6ex}{2pt}%
{\small \sffamily\centering\vspace{-2.65ex}\MakeUppercase}}
%\allsectionsfont{\raggedright\ulemheading{\uuline}}
\subsectionfont{\sffamily\MakeUppercase}
\newcommand\firstoftwo[2]{#1}
\newcommand\secondoftwo[2]{#2}
\newcommand\ContactUs[9]{%
{\small \sffamily 
\firstoftwo#1\hfill\\% 
\textbf{\Large \XXX} \firstoftwo#2~~$\circ$~~%
\textbf{\Large \YYY} \secondoftwo#2\\
\textbf{\Large \ZZZ} \firstoftwo#3 \hfill\\
}
\begin{quoting}
\footnotesize\Fontskrivan%\calligra ... 
\firstoftwo#7
\end{quoting}
\begin{minipage}[c]{\linewidth}
\color{gray}
\offinterlineskip
\rule[0ex]{\linewidth}{.2ex}\vspace{.5mm}
\rule[0ex]{\linewidth}{.4ex}
\end{minipage}
\vspace{-5ex}
}

\newcommand\ZZZ[6]{%
{\footnotesize\sffamily%
\textbf{ Wow:} #1\hfill%\\
\textbf{Bow:} #4 \hfill%
}}

\usepackage{sectsty}我相信这些与该包相关。

我正在使用\usepackage{sectsty}来很好地装饰每个\section{xxxx}。我想在每个部分之后开始一个新页面,以避免浮动问题。因此,理想情况下,我希望每个部分都单独编译,独立于其他部分。当 latex 算法运行并决定放置图表和表格时,我想欺骗它相信每个部分都是独立的,并且后面没有任何内容。我该如何实现这一点?

我以为只需放置一个\pagebreak\newpage甚至一个\clearpage就可以了。不幸的是,每当我这样做时,我的内容就会发生奇怪的事情\section

命令...我收到错误消息

>>! Package sectsty Error: Can't use \sectionrule with \centering.

>>See the sectsty package documentation for explanation.

>>Type  H <return>  for immediate help.

>> ... 

我为每个部分设计的格式都丢失了。有什么解决办法吗?

哦,是的,我运行 pdflatex。

答案1

在给定的 MWE 代码中存在几个错误和不必要的包。

我做了一些漂亮的打印,删除了对这个问题不需要的包的调用,并得到了一个正在运行的 MWE。我删除了宏\centering。请参阅最后一张图片以了解如何将其居中。

如果我误解了某些内容,请复制我的 MWE,进行更改并向我们展示您的问题。

梅威瑟:

\documentclass[twocolumn]{book}

\usepackage[T1]{fontenc}

\usepackage{caption}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{pgfplots}

\usepackage{titletoc}
\usepackage{blindtext}% dummy text
\usepackage{geometry,xcolor,amssymb,amsmath,graphicx}% 

\usepackage{sectsty} 
\sectionfont{\sectionrule{1.4ex}{2pt}{-.6ex}{2pt}%
{\small \sffamily\centering\vspace{-2.65ex}\MakeUppercase}}
%\allsectionsfont{\raggedright\ulemheading{\uuline}}
\subsectionfont{\sffamily\MakeUppercase}
\vspace{-5ex}

\usepackage[colorlinks=true,urlcolor=blue]{hyperref}% dummy text

\contentsmargin{0cm}

% End of preamble ===========================


\begin{document}

\chapter{Hello world}
\blindtext[2]
\section{Hello section title}
\blindtext[2]
\subsection{some tables and figures here}
\blindtext[1]
\subsection{testing}
\blindtext[2]
\begin{tikzpicture}[thick,scale=.6]
  \begin{axis}[%
    ybar,
    tick label style={font=\small},
    tickpos=left,
    xticklabels={}, 
    xtick={1,2,3,4},
    ymin=0,
    legend entries={$0-4$ years, $5-9$ years, $>10$ years },
    y tick label style={/pgf/number format/.cd,%
        scaled y ticks = false,
        set thousands separator={},
        fixed
    },
  ]
    \addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.23) };
    \addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.51) };
    \addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.26)  };
  \end{axis}
\end{tikzpicture}


\subsection{hello}

\section{section title here}
\blindtext[1]
\subsection{something}
\blindtext[1]
\subsection{something else}
\blindtext[2]
\subsection{another subsection}
\blindtext[1]
\subsection{here is a subsection}
\blindtext[1]

\begin{figure}
\centering
\begin{tikzpicture}[thick,scale=.6]
\begin{axis}[
ybar,
tick label style={font=\small},
tickpos=left,
xticklabels={}, 
xtick={1,2,3,4},
ymin=0,
legend entries={$0-4$ years, $5-9$ years, $>10$ years },
y tick label style={/pgf/number format/.cd,%
      scaled y ticks = false,
      set thousands separator={},
      fixed
},
]
\addplot +[bar shift=-.4cm, area legend] coordinates {(1,0.42) };
\addplot  +[bar shift=.0cm, area legend]coordinates {(1,0.28) };
\addplot  +[bar shift=.4cm, area legend]coordinates {(1,0.3)  };

\end{axis}
\end{tikzpicture}
\end{figure}


\end{document}

更新:

在更新的 MWE 中,您\centering在第 59 行和第 143 行使用了宏。生成的错误消息:

! Package sectsty Error: Can't use \sectionrule with \centering.

\centering%MWE 编译进行注释。

此宏将以下内容居中。您可以使用

{% begin a group
 \centering  %centering starts now
 code, to be centered ...
}% ends group, ends \centering 

关门 后 停止 定心}.

在您的情况下,第 87\centering行仍然在工作。\section{New Section}这会导致错误。

相关内容