Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

UPDATE WHERE IT BREAKS DOWN... PLEASE REFER TO CODE BELOW. I ADDED ONE MORE PACKAGE and ONE DEFINITION

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

So, I amended the Kurt's generous and insightful solution and it appears to break down as I include other information .... for instance the \hello macro ... I believe that was one of the reasons I used the extraplaceins package in my original solution.

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

Update:

As Mico correctly pointed out, I did not provide the entire context to the problem. I am using the following environment:

\documentclass[twocolumn]{book}

and related hopefully relevant info follow below

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

These are the ones relevant for the \usepackage{sectsty} package I believe.

I am using the \usepackage{sectsty} for nicely decorating each \section{xxxx}. I'd like to start a new page after each section so as to avoid floating problems. So, ideally, I'd like to have each section compile individually and independently of others. When the latex algorithm runs through and decides to placings of figures and tables, I'd like to fool it into believing that each section is on its own and nothing follows after it. How can I accomplish this ?

I thought that simply placing a \pagebreak or \newpage or even \clearpage will do this. Unfortunately, whenever I do this something weird happens with my content in the \section

command ... I obtain error messages

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

>>See the sectsty package documentation for explanation.

>>Type  H <return>  for immediate help.

>> ... 

And the formatting that I designed for each section is lost. Is there any work around ?

Oh, yes, I run pdflatex.

share|improve this question
1  
Welcome to TeX.SE! Please add a MWE (minimum working example) that shows how you use the sectsty package to "decorate" section headers and that generates the error and warning messages you get. Incidentally, have you tried inserting the instruction \usepackage[section]{placeins} in the preamble? Doing so should prevent any floats from being placed after the start of the next section, irrespective of what you do with section header decorations. –  Mico Aug 9 '13 at 1:02
    
@mico.@Mico. I did try to use \usepackage[section]{placeins}' package. but since I am already in need to use \usepackage[section, subsection and subsubsection]{extraplaceins}' won't work I am receiving compilation error msgs. `! LaTeX Error: Command \@fb@secFB already defined.' –  Eric Aug 9 '13 at 2:26
    
The fact that you're already using the placeins package is material information you should mention up front, in the body of your posting. Please post an MWE showing what you've done so far; the information you've posted up to now simply doesn't allow a decent diagnosis of what may be going wrong. –  Mico Aug 9 '13 at 2:32
1  
The formatting of your question is really hard to read ... really hard. Tidying it up would be useful. Also a real minimal example (or here) is still to be desired. –  jon Aug 9 '13 at 3:01
4  
titlesec and sectsty fight with each other. Either of them can be used, but not both. –  egreg Aug 9 '13 at 8:02
show 13 more comments

1 Answer

There are several errors and unnecessary packages in the given code for the MWE.

I did a little pretty printing, removed calls to unneeded packages for this problem and got a running MWE. I deleted the macro \centering. See the last image for how to center it.

If I misunderstood something please copy my MWE, change it and show us your problem.

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}

Update:

In your updated MWE you used macro \centering in lines 59 and 143. The resulting error message:

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

Comment both \centering with % and your MWE compiles.

This macro centers everything following. You can use

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

to stop centering after the closing }.

In your case \centering is still workíng for \section{New Section} in line 87. That causes the error.

share|improve this answer
    
I see where this is heading. I experimented with a more fully fledged version where it breaks down. Please take a look ... assuming the same packages I included : please see above since it does not fit here. –  Eric Aug 10 '13 at 5:34
    
@Eric you defined a macro \newcommand\firstoftwo[2]{#1} for two arguments but it uses only one. See also that the inside the \url macro used macro is printed and not executed ... –  Kurt Aug 10 '13 at 14:52
    
hmm not sure how to improve this. and yes, one of the arguement will be a URL .... I have just now only inputted numbers .... how to I remedy the situation and make it work. Also, in first place u will alsway get a mini graphics included. i.e. \hello{{\includegraphics[scale=.4]{...} some text}}{{......}....}. –  Eric Aug 11 '13 at 2:32
    
please see the new code which makes use of ur MWR and adds one package and one new command ... these cause the \sectionsty compilation problem. –  Eric Aug 15 '13 at 15:00
    
can you please take another look at this ? –  Eric Aug 27 '13 at 5:50
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.