I wish to customize the background color and the weight and color of the border using titlesec (not using mdframed).  %-----------------------------------------------------------------------------------% \documentclass[11pt,a4paper,reqno,fleqn,xcolor=x11names]{book} % %---------------------------------------------------------------------------------- % % \usepackage{amsthm,amsmath,amsfonts} % \usepackage{titlesec} % \usepackage[dotinlabels]{titletoc} % more advanced but essential here \usepackage[english]{babel} %  \titleformat{\section}[frame] % {\bfseries\itshape\fontsize{12.8}{14}\selectfont}         {}{8pt} {\;\;\thesection\hskip 0.7em}  \begin{document}  \chapter{This is Chapter No 1}  \section{A titletec section in a frame - too tall and not shaded}  \end{document}
121933
%---------------------------------------------------------------------------------------------------------- % \documentclass[11pt,a4paper,reqno,fleqn,xcolor=x11names]{book} % %---------------------------------------------------------------------------------------------------------- % % \usepackage{amsthm,amsmath,amsfonts} % \usepackage{titlesec} % \usepackage[dotinlabels]{titletoc} % more advanced but essential here \usepackage[english]{babel} %   \titleformat{\section}[frame] % {\bfseries\itshape\fontsize{12.8}{14}\selectfont}         {}{8pt} {\;\;\thesection\hskip 0.7em}  \begin{document}  \chapter{This is Chapter No 1}  \section{A titlesec section in a frame - too tall and not shaded}  \end{document}
101402
I was thinking about giving a finishing touch to my resume by adding a border to the document in black color. I tried using \fancybox but not impressed with the output.  \documentclass[a4paper]{article}  \usepackage[a4paper,vmargin={20mm,20mm},hmargin={20mm,20mm}, includehead,%  includefoot]{geometry}  \usepackage{fancybox}  \begin{document}  \fancypage{\setlength{\fboxsep}{0pt}\fbox}{}  Document text goes here...  \end{document}   The output that I am trying to get is something similar like this.    How do  I get multiple recessed rectangle covering the whole page ?
78266
I am trying to change the font and format of heading using titlesec package. However it gives me the following error.    Missing { inserted \tableofcontents &lt;br&gt; Missing { inserted \chapter{Introduction}    The code:  \documentclass[10pt, letterpaper]{report} \usepackage{thesis}   \usepackage{titlesec} \renewcommand{\chaptername}{CHAPTER}{\Large} \titlespacing*{\chapter}{0pt}{0.5in}{0.3in} \titleformat{\chapter}[display]         {\normalfont\Large\centering\uppercase}{\chaptertitlename\ \thechapter}{0pt}{\Large} \titleformat{\section}{\large\bfseries}{\thesection}{1em}{}   \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  \tableofcontents  \chapter{Introduction}  Some text.  \end{document}
75742
I would like to make colored, upper case section titles. But somehow, the translation for all section items fails with:   ! Missing number, treated as zero. &lt;to be read again&gt;  ! Color stack action is missing. &lt;to be read again&gt;  ! Package xcolor Error: Undefined color `BLUE'.   I figured out that the conflict occurs when I am trying to combine the \MakeUppercase command in the \titleformat environment together with the xcolor package.  A MWE of my problem:  \documentclass{article}   \usepackage{xcolor} \usepackage{titlesec}  \titleformat{\section}   {\normalfont\bfseries\MakeUppercase}{\thesection}{1em}{}  %this line does not work  %{\normalfont\bfseries}{\thesection}{1em}{}                %works perfectly well  \begin{document} \section{\color{blue} This is a blue, upper case section} \end{document}   I work with Texmaker/MikTeX 2.9. Any ideas how this issue can be solved?
90108
Im trying to recreate this () chapter, however it is not quite working as it says in the comments. I am now doing this, for numbered chapters, however I cannot get the chapter title on the line, instead of right as in the picture. The chapter title should thus be on the line, as far to the right as possible. Also, I have no clue what the 110 stands for (I adjusted it, but nothing changes), so if anyone knows, it would really help me understand the code haha! In addition the fontsize of the chapter name does not seem to change as expected when I change it (I do this in the \normalfont\Large\sffamily by changing \Large to different sizes, but it only changes a little when I change it to \HUGE for instance. It was in the original code done with #1, but I get a "1" in the pdf.  \titleformat{\chapter}[block] {\normalfont\Large\sffamily}{}{0pt} {\parbox[t]{\chapnumb}{%    \fontsize{100}{110}\selectfont\thechapter}%   \parbox[b]{\dimexpr\textwidth-\chapnumb\relax}{     \raggedleft     \hfill{\LARGE}     \rule{\dimexpr\textwidth-\chapnumb\relax}{0.9pt}}}
7058
I am creating a custom WPF control that let's say for simplicity sake has a vertical stack panel with a "title" TextBlock, followed by a ContentPresenter. I want the font size for the "title" to be 5 Points LARGER than the size used in the content, which is inherited by whatever container the user places this control in.  How can I specify a font size in the control template for the header element using a relative value without exposing a property like "TitleFontSize" to the user? I want do "add 5".  I tried using a ScaleTransform on the header text block with mixed results (the text block scaled fine but the orientation was modified - I had the text right-justified and it moved "off the control" area when scaled). Also, I am not sure if scale transform would be approprite here.
32329
I am currently writing my PhD thesis, and I have trouble defining a common style for my global TOC and the partial TOCs generated by titletoc.  Basically if you check the following MWE, I like the general style of the global TOC, in particular the fact that hyperref links include the labels. However, I find that the dotted lines in the global TOC are not dense enough, and prefer those of the partial TOCs.  \documentclass[12pt,a4paper]{book}  \usepackage{caption} \usepackage{titletoc} \usepackage[colorlinks]{hyperref} \usepackage{lipsum}  \renewcommand{\cleardoublepage}{\clearpage}  \newcommand{\PartialToc}{\vspace*{0.5pc}\vbox{\bf\large\noindent Chapter contents}\vspace*{0.3pc}\startcontents[chapters]\vspace*{0.3pc}\printcontents[chapters]{p}{1}{}\vspace*{0.3pc}}  \begin{document}  % Custom style for partial TOCs \titlecontents{psection}[3.6em]{\small\bfseries}{\contentslabel{1.8em}}{}{\mdseries\titlerule*[0.25pc]{.}\contentspage\hspace*{1.8em}}{} \titlecontents{psubsection}[6.0em]{\small}{\contentslabel{2.4em}}{}{\titlerule*[0.25pc]{.}\contentspage\hspace*{1.8em}}{}  \tableofcontents \listoffigures \listoftables  \chapter{Chapter 1}  \vfill \lipsum[1-2] \vfill\PartialToc\clearpage  \section{Section 1} \lipsum[1]  \begin{figure}[t]     \caption{Figure 1} \end{figure}  \section{Section 2} \lipsum[1] \subsection{Subsection 2.1} \lipsum[1] \subsection{Subsection 2.1} \lipsum[1] \section{Section 3} \lipsum[1]  \begin{table}[t]     \caption{Table 1} \end{table}  \end{document}   Therefore, I tried to increase the density of the dotted lines in the global TOC, by adding the following titletoc style declarations after \begin{document}:  \titlecontents{section}[3.8em]{}{\contentslabel{2.3em}}{\hspace*{-2.3em}}{\titlerule*[0.25pc]{.}\contentspage}{} \titlecontents{subsection}[6.2em]{}{\contentslabel{2.9em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}   However, in this case, the hyperref links are changed, which I would like to avoid (no I am not a maniac...). Is there a way to achieve this ? And can this also be used to make the hyperref links in the partial TOCs include the labels ?  And as a subsidiary question, how do I assign the same style to entries in the List of Figures and List of Tables ?  Thank you for your help
33903
I'd like to style a caption in a specific way, but I can't seem to figure out the proper settings to do so.  First off, I'd like to change the label from "Listing" to "Algorithm" when I use \captionof{lstlisting}{foo}  Secondly, I'd like to make the "Algorithm 1" part be bold with the rest of the label non boldface  Thirdly, I'd like to have a line above the caption.  Here's an image of something akin to what I'd like to achieve, and following is my code.    And this is what I have:    \documentclass{article}  \usepackage{listings} \usepackage{caption} \usepackage{geometry} \usepackage{DejaVuSans} \usepackage{DejaVuSansMono} \renewcommand*\familydefault{\ttdefault}  \geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in }  \lstset{   frame=top,frame=bottom,   basicstyle=\small\normalfont\sffamily,    % the size of the fonts that are used for the code   stepnumber=1,                           % the step between two line-numbers. If it is 1 each line will be numbered   numbersep=10pt,                         % how far the line-numbers are from the code   tabsize=2,                              % tab size in blank spaces   extendedchars=true,                     %   breaklines=true,                        % sets automatic line breaking   captionpos=t,                           % sets the caption-position to top   mathescape=true,   stringstyle=\color{white}\ttfamily, % Farbe der String   showspaces=false,           % Leerzeichen anzeigen ?   showtabs=false,             % Tabs anzeigen ?   xleftmargin=17pt,   framexleftmargin=17pt,   framexrightmargin=17pt,   framexbottommargin=5pt,   framextopmargin=5pt,   showstringspaces=false      % Leerzeichen in Strings anzeigen ?  }  \DeclareCaptionFormat{listing}{#1#2#3} \captionsetup[lstlisting]{format=listing,singlelinecheck=false, margin=0pt, font={sf}}  \DeclareMathVersion{sans} \SetSymbolFont{operators}{sans}{OT1}{cmbr}{m}{n} \SetSymbolFont{letters}  {sans}{OML}{cmbrm}{m}{it} \SetSymbolFont{symbols}  {sans}{OMS}{cmbrs}{m}{n}  \lstnewenvironment{sflisting}[1][]   {\lstset{#1}\mathversion{sans}}{}   \begin{document}  \begin{sflisting}[caption=Spanning tree broadcast algorithm.] Initially $\langle M\rangle$ is in transit from $p_{r}$ to all its children in the spanning tree.  Code for $p_{r}$: 1:  upon receiving no message:                                          // first computation event by $p_{r}$ 2:      terminate  Code for $p_{i},\ 0\leq i\leq n-1,\ i\neq r$: 3:  upon receiving $\langle M\rangle$ from parent: 4:      send $\langle M\rangle$ to all children 5:      terminate \end{sflisting} \end{document}
9513
I want my chapter titles to look like as asked in this . I have followed the method suggested by "lockstep", that is, using package titlesec. It works perfectly fine but here is the question: I want this format for main chapters only and for the rest, that is Contents, Declaration, Index, Bibliography etc I want them centered with normal vertical spaces before and after the title. Pasting the code at the start of Chapter 1 solves the problem partially; it leaves the starting ones (contents, declaration) totally unchanged and applies the same format to Index and Bibliography. Please help.
36322
I posted this at  and got redirected here. This does indeed look like a better place to ask.  I would like to decorate my headlines (section, subsection, etc.) by adding a background color. I would like this box filled with a single solid color to span across the entire typearea.  This picture is a screenshot of an OpenOffice document where the headline has the formating, layout and color I want.    Requirements on a solution   The resulting style is supposed to be used by others, meaning an equivalent latex output to the picture above shall be created by this code:  Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text   \subsubsection{This is a headline}  Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text  If the section is supposed to be unnumbered one should be using \subsubsection*. LaTeX still needs to be in charge of the whitespace between paragraphs and the blue box.   What I have tried so far  As far as I can google the headline together with the section numbering are a simple paragraph. Latex adds some skips before and after and squeezes in a few commands that modify the font(s).  My ideas revolve around locking this paragraph in a \colorbox. The colorbox macro works like this: \colorbox{color}{the content around which to draw a box filled with the specified color}. My problem is I can't get a grasp on this paragraph.  The easy 80%  My work is based on koma-script and by redefining \othersectionlevelsformat and \(sub)*section. I can draw two boxes, one surrounding the section numbering and another surrounding the section title. However this has 3 open issues:   the upper edges of the boxes are unaligned and the box with the title is slightly larger than the line with the numbering The box around the title does not strech to the right end of the typearea the box around the numbering doesn't grow if the title spans multiple lines (no surprise here)   The hard 20%  I tried to make latex put the section numbering into a \savebox I could access later and put as part of the title. That would eliminate the need for two boxes and solve all three of my problems at once, but that doesn't work. I only get to modify the title before the actual numbering is done. So while I can put the numbering into a savebox, I can't do anything with it until it's too late.  I tried putting the \section ... statement into a colorbox, but it doesn't like that and the document fails to compile with ! LaTeX Error: Something's wrong--perhaps a missing \item. The same holds for saveboxes. I guess colorbox uses those.  I tried putting the \section ... statement in a minipage and put a box around that. This has two issues. 1st: latex doesn't put any empty space above a section. 2nd: not only the section numbering and title have the background but also the empty space between section title and first paragraph.  So how can one hack latex to do a section title formating as shown in the screenshot above?
102074
I am trying to reproduce a word report template in LaTeX to speed up my report writing.  I have some basic LaTeX skill, but I am having trouble producing the blue page border as shown in the picture.  I also don't know how to create the header information with the page border and the Title inside the blue box.  I assume that the package TikZ can be used to draw the page border, and fancyheader for the header information but how to use the packages together is causing me confusion.    I have attached an image of the basic word document I am trying to reproduce. Note all information shown is to be repeated on every page.  Any help and direction is appreciated.
36069
How do I specify the fonts, and general font size, for the titles, chapters and sections in my document  Update:  I can see how my question is confusing.  I use \section and \chapter etc. to organise my document, and I would like to change the way the section and chapter titles are displayed.
103276
This is Roger Penrose' book The Road to Reality's title   Currently my document begins like this,      \documentclass{report}     \usepackage{bm}     \usepackage{xcolor}     \usepackage{varwidth}     \usepackage{array}     \usepackage{geometry}     \usepackage[pdftex,bookmarks=true]{hyperref}     \usepackage{pdfpages}     \usepackage{amsmath}     \usepackage{amssymb}     \usepackage{graphicx}     \usepackage{amsthm}     \usepackage{tikz-cd}     \usetikzlibrary{cd}     \usepackage{tikz}     \usepackage{appendix}     \usepackage{eso-pic}     \usetikzlibrary{positioning}     \usepackage[explicit]{titlesec}     \RequirePackage{fix-cm}      \definecolor{bluegreen}{rgb}{-.2,.4,0.6}      \newcommand\semihuge{\@setfontsize\semihuge{18.72}{20.38}}      \titleformat{\chapter}[display]         {\normalfont\huge}         {\hspace*{-60pt}\thechapter.~#1}         {-10pt}         {\hspace*{-110pt}\rule{\dimexpr\textwidth+20pt\relax}{0pt}}     \titleformat{name=\chapter,numberless}[display]%conents         {\normalfont\bfseries\huge}         {\hspace*{175pt}#1}         {-12pt}         {\hspace*{-110pt}\rule{\dimexpr\textwidth+30pt\relax}{0pt}}         \titlespacing*{\chapter}{0pt}{0pt}{30pt}       \geometry{     top=20mm,     total={145mm,230mm}     }     \hypersetup{         colorlinks=true,         linkcolor=bluegreen,         filecolor=magenta,         urlcolor=cyan,         pdftitle={Sharelatex Example},         bookmarks=true,     }     \tikzset{&gt;=stealth}      \newcommand\BackgroundPic{         \put(0,0){             \parbox[b][\paperheight]{\paperwidth}{%                 \vfill                 \centering                 \includegraphics[width=\paperwidth,height=\paperheight]{BackGroundPDF.pdf}                 \vfill             }}}         \begin{document}      \begin{titlepage}     \end{titlepage}     \pagenumbering{roman}      \title{\Huge\textsc{The Road to Reality}}     {}     \date{}      \maketitle     \newpage       \tableofcontents     \newpage      \clearpage     \pagenumbering{arabic} \end{document}
25445
So far everything I found on the matter of borders only applies to the text mode.  I want to be able to do something like  $x_i = y$   so the result will be like the ordinary "xi = z" formula with the border around "i"?  The common answers seems to be the fbox or boxed commands. Yet they render their argument in the standart mode, unless specified to do otherwise with the specific mode. For example, the following code  \[ x_i, \boxed{x}_i, x_{\boxed{i}}, \boxed{x}_{\boxed{i}} \]   produces two normal xi figures, and another two with an oversized i.
61857
Basically, here's my MWE, and I need to include "Chapter" before every section title in the ToC (without changing anything else).      \documentclass[12pt]{article} \usepackage[utf8]{inputenc}  \usepackage[english]{babel} \usepackage[titles]{tocloft} \usepackage{titlesec} \usepackage{titletoc}  \addto\captionsenglish{ \renewcommand*\contentsname{\centerline{TABLE OF CONTENTS}}}  %\renewcommand{\thesection}{CHAPTER} %\renewcommand{\cftsecpresnum}{Chapter \thesection} \titleformat{\section}[display]% {\null\vskip1em\sffamily\bfseries\filcenter}{Chapter \thesection}{0em}{}[] \titlespacing*{\section}{0em}{1em}{1em}  \titlecontents{section} [1.5em] % ie, 1.5em (chapter) + 2.3em {} {\contentslabel{1em}} {\hspace*{-1.5em}} {\titlerule*[0.5pc]{.}\contentspage}  \begin{document} \newpage \tableofcontents \newpage  \section{Section One} \section{Section Two} Content \end{document}   The commented out code is what I've already tried. The first one just changes the number to "CHAPTER" and doesn't move the text in the ToC (so it just overlays on top of the name of the section), and if I include "\thesection" after "CHAPTER" it creates an infinite loop definition error. The second one causes no differences, and the code still compiles.  Thanks!
45667
I used the following piece of code to put a box around each page in my report  \documentclass[12pt,a4paper,oneside,final,times]{report}  \AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}}  \usepackage{graphicx} \usepackage[a4paper]{geometry} \usepackage[english]{babel} \usepackage{fancyheadings} \usepackage{fancybox} \usepackage{setspace} \usepackage{fixltx2e} \usepackage{amssymb,amsmath} \usepackage{pgf} \usepackage{pgfpages} %\usepackage{fncychap}  \usepackage{lipsum,titletoc} \usepackage{titlesec} \usepackage{simplemargins} \pgfpagesdeclarelayout{boxed} { \edef\pgfpageoptionborder{0pt} } { \pgfpagesphysicalpageoptions {% logical pages=1,% } \pgfpageslogicalpageoptions{1} { border code=\pgfsetlinewidth{2pt}\pgfstroke,% border shrink=\pgfpageoptionborder,% resized width=.90\pgfphysicalwidth,% resized height=.85\pgfphysicalheight,% center=\pgfpoint{.53\pgfphysicalwidth}{.5\pgfphysicalheight}% }% }  \pgfpagesuselayout{boxed} \pagestyle{fancy}   but this is causing my page numbers to be different from that of the toc. To be specific, page numbers in toc=page number on page +1.  Any solution for this, please? The code is borrowed from
41602
I frequently create labels that follow the same format: white text on a 75% opaque black background, with 10px of margin around the text. Currently, I have to manually build these labels, which takes a lot of work.  In one method, I write the text, figure out its height and width, then create a separate rectangle and place it behind it. This takes a lot of clicking around for every label.  In the other method, I draw out a text box, select it directly, give it the correct background and margins, and then insert the text. However, I must then resize the box manually, meaning more clicking around and greater imprecision. There doesn't seem to be a way to directly select a text box once it has text inside it.  I tried using the script contained in  to resize the text box to the content, but it only resizes the box vertically, and removes my color and margins.  Does anyone have suggestions on how to resolve these problems, or for a better method? I'm using CS3.