4

I would like to know how to tidy up the code and use newcommand or environment for special section. I have the code here but it's not very smart. I used brute force method. Plus, section numbering are black. Also, I would like that section background would be a bit smaller. If you have better or smarter way to make this similar, please help. Idea is from http://www.latextemplates.com/template/the-legrand-orange-book

\documentclass[12pt,a4paper]{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[some]{background}
\usepackage{lipsum}

\definecolor{titlepagecolor}{cmyk}{1,.60,0,.40}

\backgroundsetup{
scale=1,
angle=0,
opacity=.9,
contents={\begin{tikzpicture}[remember picture,overlay]
 \path [fill=titlepagecolor] (current page.west)rectangle (current page.north east); 
 \draw [color=white, very thick] (4,0)--(4,0.5\paperheight);
\end{tikzpicture}}
}

\makeatletter                   
\def\printauthor{%                  
    {\large \@author}}          
\makeatother

\author{%
    ghfghfg  \\
    Department name \\
    \texttt{email1@example.com}\vspace{40pt} \\
    fgdfgdfgd \\
    dfgdfgdfgdfg \\
    \texttt{email2@example.com}
    }

\begin{document}
\BgThispage
\newgeometry{left=1cm,right=6cm,bottom=2cm}

\tableofcontents


\begin{abstract} 
An abstract is a brief summary of a research article, thesis, review, conference proceeding or any in-depth analysis of a particular subject or discipline, and is often used to help the reader quickly ascertain the paper's purpose. When used, an abstract always appears at the beginning of a manuscript, acting as the point-of-entry for any given scientific paper or patent application. Abstracting and indexing services for various academic disciplines are aimed at compiling a body of literature for that particular subject.
    \end{abstract}


\begin{titlepage}
\BgThispage
\newgeometry{left=1cm,right=6cm,bottom=2cm}

\section{\textcolor{white}{\Huge\textbf{\textsf{First section}}}}
\vspace*{0.4\textheight}
\noindent
\vspace*{2cm}\par
\noindent
\begin{minipage}{0.35\linewidth}
    \begin{flushright}
        \printauthor
    \end{flushright}
\end{minipage} \hspace{15pt}
%
\begin{minipage}{0.02\linewidth}
    \rule{1pt}{175pt}
\end{minipage} \hspace{-10pt}
%
\begin{minipage}{0.63\linewidth}
\vspace{5pt}
    \begin{abstract} 
An abstract is a brief summary of a research article, thesis, review, conference proceeding or any in-depth analysis of a particular subject or discipline, and is often used to help the reader quickly ascertain the paper's purpose. When used, an abstract always appears at the beginning of a manuscript, acting as the point-of-entry for any given scientific paper or patent application. Abstracting and indexing services for various academic disciplines are aimed at compiling a body of literature for that particular subject.
    \end{abstract}
\end{minipage}
\end{titlepage}
\restoregeometry


\newpage

\BgThispage
\newgeometry{left=1cm,right=6cm,bottom=2cm}

\section{\textcolor{white}{\Huge\textbf{\textsf{Second section}}}}
\vspace*{0.4\textheight}
\noindent
\vspace*{2cm}\par
\noindent
\begin{minipage}{0.35\linewidth}
    \begin{flushright}
        \printauthor
    \end{flushright}
\end{minipage} \hspace{15pt}
%
\begin{minipage}{0.02\linewidth}
    \rule{1pt}{175pt}
\end{minipage} \hspace{-10pt}
%
\begin{minipage}{0.63\linewidth}
\vspace{5pt}
    \begin{abstract} 
An abstract is a brief summary of a research article, thesis, review, conference proceeding or any in-depth analysis of a particular subject or discipline, and is often used to help the reader quickly ascertain the paper's purpose. When used, an abstract always appears at the beginning of a manuscript, acting as the point-of-entry for any given scientific paper or patent application. Abstracting and indexing services for various academic disciplines are aimed at compiling a body of literature for that particular subject.
    \end{abstract}
\end{minipage}

\end{document}
  • 1
    Back ticks are for inline code. Highlight it and click the {} button to indent it by 4 spaces. – cfr Mar 29 '15 at 23:59
  • There is rather a lot here which is not at all ideal. Including manual formatting in the arguments of \section{}, for example, is a Really Bad Idea(TM). Have you looked into using something like titlesec? (Can't stand it myself but others seem to like it. I only use it for answering questions.) – cfr Mar 30 '15 at 0:00
  • No, don't know titlesec. I know the code is bad. Is't brute force method. – vejn Mar 30 '15 at 0:03
  • Why do you add vertical space after the contents and then start a new page? And the change to the geometry of the page. You restore it and then immediately change it to just what it was before. – cfr Mar 30 '15 at 0:04
  • I removed vspace after contents. In section it has to be or else there is overlaping background color with Abstract. Geometry is just for section so it has to change when needed and restore when not needed. I would like something as Legrand book but simpler and for article latextemplates.com/template/the-legrand-orange-book – vejn Mar 30 '15 at 0:10
5

Here's a slightly cleaner version but it still leaves a good deal to be desired...

\documentclass[12pt,a4paper]{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[some]{background}
\usepackage{titlesec,afterpage}

\definecolor{titlepagecolor}{cmyk}{1,.60,0,.40}

\backgroundsetup{
  scale=1,
  angle=0,
  opacity=.9,
  contents={\begin{tikzpicture}[remember picture,overlay]
      \path [fill=titlepagecolor] (current page.west)rectangle (current page.north east);
      \draw [color=white, very thick] (4,0)--(4,0.5\paperheight);
    \end{tikzpicture}}}

\makeatletter
\def\printauthor{%
  {\large \@author}}
\makeatother

\author{%
  ghfghfg  \\
  Department name \\
  \texttt{email1@example.com}\vspace{40pt} \\
  fgdfgdfgd \\
  dfgdfgdfgdfg \\
  \texttt{email2@example.com}
}

\titleformat{\section}[hang]{%
  \BgThispage\color{white}\Huge\bfseries\sffamily
}{\thesection}{1.5em}{}

\newcommand\myabstract[2][\printauthor]{%
  \vspace*{.5\textheight}\par
  \noindent
  \begin{minipage}{0.35\linewidth}
    \begin{flushright}
      #1
    \end{flushright}
  \end{minipage}\hspace{15pt}
  %
  \begin{minipage}{0.02\linewidth}
    \rule{1pt}{175pt}
  \end{minipage}\hspace{-10pt}
  %
  \begin{minipage}{0.63\linewidth}
    \vspace{5pt}
    \begin{abstract}
      #2
    \end{abstract}
  \end{minipage}
  \restoregeometry}

\begin{document}

  \newgeometry{left=1cm,right=6cm,bottom=2cm,showframe}
  \savegeometry{geometrysec}
  \tableofcontents

  \loadgeometry{geometrysec}
  \section{First section}

  \myabstract{%
    An abstract is a brief summary of a research article, thesis, review, conference proceeding or any in-depth analysis of a particular subject or discipline, and is often used to help the reader quickly ascertain the paper's purpose. When used, an abstract always appears at the beginning of a manuscript, acting as the point-of-entry for any given scientific paper or patent application. Abstracting and indexing services for various academic disciplines are aimed at compiling a body of literature for that particular subject.}

  Some text.

  \loadgeometry{geometrysec}
  \section{Second section}

  \myabstract{%
    An abstract is a brief summary of a research article, thesis, review, conference proceeding or any in-depth analysis of a particular subject or discipline, and is often used to help the reader quickly ascertain the paper's purpose. When used, an abstract always appears at the beginning of a manuscript, acting as the point-of-entry for any given scientific paper or patent application. Abstracting and indexing services for various academic disciplines are aimed at compiling a body of literature for that particular subject.}

  Some more text.

\end{document}

slightly cleaner...

  • I've found that section background images are being the same. I checked and I've put the correct ones. Don't know why is this happening. – vejn Jan 4 '16 at 12:15
  • Aren't they meant to be the same? – cfr Jan 4 '16 at 20:33
  • No, I added some different ones for different sections and it's strange how they repeat. They repeat twice than goes next image. While I checked I did not repeate same image for different section. This happens if you have more than 3 sections. – vejn Jan 4 '16 at 22:06
  • I think you should ask a new question since I don't really understand what you are trying to do now or how it relates to this question/answer, where you're just creating a standard backdrop for all sections. – cfr Jan 4 '16 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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