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.

I am trying to prepare a class for my college magazine and articles. I would like to know how to place a black box on the top margin of the first page and write some huge text inside it in white color. Present style of the document looks like this,

% DOCUMENT LAYOUT
\documentclass[10pt, a4paper]{article}
\usepackage[left=5cm,right=2.5cm,top=5cm,bottom=3cm]{geometry}
\usepackage{fontspec}
\usepackage{marvosym}
\usepackage{wasysym}
% DOCUMENT LAYOUT
\setlength\parindent{0cm}
\usepackage[libertine={Ligatures=TeX,Numbers=OldStyle}]{libertineotf}
\setsansfont{Segoe UI}
% FONTS
\usepackage[usenames,dvipsnames]{color}
\usepackage{xunicode}
\usepackage{xltxtra}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{pgfplots}
\usepackage{xcolor}
\usepackage{eso-pic}

% ---- CUSTOM COMMANDS
\chardef\&="E050
\newcommand{\html}[1]{\href{#1}{\scriptsize\textsc{[html]}}}
\newcommand{\pdf}[1]{\href{#1}{\scriptsize\textsc{[pdf]}}}
\newcommand{\doi}[1]{\href{#1}{\scriptsize\textsc{[doi]}}}
% ---- MARGIN YEARS
\usepackage{marginnote}
\newcommand{\amper{}}{\chardef\amper="E0BD }
\newcommand{\sides}[1]{\marginnote{\color{MidnightBlue}\sffamily #1}}
%\newcommand{\years}[1]{\marginnote{\footnotesize #1}}
%\renewcommand*{\raggedleftmarginnote}{}
\setlength{\marginparsep}{0.5cm}
\reversemarginpar

% HEADINGS
\usepackage{sectsty} 
\usepackage[normalem]{ulem} 
\sectionfont{\mdseries\upshape\Large}
\subsectionfont{\mdseries\scshape\normalsize} 
\subsubsectionfont{\mdseries\upshape\large}
\usepackage{lipsum}
\usepackage{tikz}
% PDF SETUP
\usepackage[bookmarks, colorlinks, breaklinks, 
    pdftitle={Here there},
    pdfauthor={My name},
    pdfproducer={}
]{hyperref}  
\hypersetup{linkcolor=blue,citecolor=blue,filecolor=black,urlcolor=MidnightBlue}
% DOCUMENT
\begin{document}
{\LARGE Effect of aspect ratio and others on others and ourselves}\\[3pt]
\textit{Me myself \& You}. Corr. author : \href{mailto:s.sssss@gmail.com}{\textit{s.sssss@gmail.com}}\\
\textit{Department of Mechanical Engineering.}\\[0.5cm]
{\large \bf Abstract}\\[4pt]
\lipsum[25]
{\section*{Introduction}}
\sides{I am hoping to create some proper paper using this template when i do my masters.}
\lipsum
\sides{How does a para look with this on sides. For a moment i thought it is gone}
\lipsum

%\vspace{1cm}
\vfill{}
%\hrulefill

\end{document}

Can some one suggest how to do this? I want something like the one on the right. enter image description here

share|improve this question
    
Are the positions of the text always equal? –  Marco Daniel Jun 4 '12 at 17:17
    
@MarcoDaniel Equal as in? I just want something similar to the photo shown where i can place a black box on top and white text. –  sgp Jun 6 '12 at 5:39
add comment

3 Answers 3

up vote 3 down vote accepted

You have a problem with xcolor. You need to use the option dvipsnames to use the color MidnightBlue. You don't need to load color because xcolor loads color. pgfplots loads tikz and you need to load xcolor before pgfplots.

You need to compile twice the next code. I used tikz to place a ablack rectangle on the first page.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode   
  % DOCUMENT LAYOUT
\documentclass[10pt, a4paper]{article}
\usepackage[left=5cm,right=2.5cm,top=5cm,bottom=3cm]{geometry}
\usepackage{fontspec}
\usepackage{marvosym}
\usepackage{wasysym}
% DOCUMENT LAYOUT
\setlength\parindent{0cm}
\usepackage[libertine={Ligatures=TeX,Numbers=OldStyle}]{libertineotf}
%\setsansfont{Segoe UI} 
\usepackage[dvipsnames]{xcolor} 
% FONTS
\usepackage{xunicode}
\usepackage{xltxtra}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{pgfplots}

\usepackage{eso-pic}

% ---- CUSTOM COMMANDS
\chardef\&="E050
\newcommand{\html}[1]{\href{#1}{\scriptsize\textsc{[html]}}}
\newcommand{\pdf}[1]{\href{#1}{\scriptsize\textsc{[pdf]}}}
\newcommand{\doi}[1]{\href{#1}{\scriptsize\textsc{[doi]}}}
% ---- MARGIN YEARS
\usepackage{marginnote}
\newcommand{\amper{}}{\chardef\amper="E0BD }
\newcommand{\sides}[1]{\marginnote{\color{MidnightBlue}\sffamily #1}}
%\newcommand{\years}[1]{\marginnote{\footnotesize #1}}
%\renewcommand*{\raggedleftmarginnote}{}
\setlength{\marginparsep}{0.5cm}
\reversemarginpar

% HEADINGS
\usepackage{sectsty} 
\usepackage[normalem]{ulem} 
\sectionfont{\mdseries\upshape\Large}
\subsectionfont{\mdseries\scshape\normalsize} 
\subsubsectionfont{\mdseries\upshape\large}
\usepackage{lipsum}
%\usepackage{tikz}
% PDF SETUP
\usepackage[bookmarks, colorlinks, breaklinks, 
    pdftitle={Here there},
    pdfauthor={My name},
    pdfproducer={}
]{hyperref}  
\hypersetup{linkcolor=blue,citecolor=blue,filecolor=black,urlcolor=MidnightBlue}
% DOCUMENT 


\begin{document}
  \thispagestyle{empty} 
  \begin{tikzpicture}[remember picture,overlay]
  \node[anchor=north west,minimum width=21cm,minimum height=8cm,fill=black,text=white] (RB) at (current page.north west){\Huge TITLE};
\node[text=white,text width=4cm,anchor=north west] at ([shift={(3cm,2cm)}]RB.south west){\emph{Petit texte afin de tester la métode. Petit texte afin de tester la métode. Petit texte afin de tester la métode.}};
\end{tikzpicture}

\vspace*{10cm}
\lipsum[1]
\newpage 
{\LARGE Effect of aspect ratio and others on others and ourselves}\\[3pt]
\textit{Me myself \& You}. Corr. author : \href{mailto:s.sssss@gmail.com}{\textit{s.sssss@gmail.com}}\\
\textit{Department of Mechanical Engineering.}\\[0.5cm]
{\large \bf Abstract}\\[4pt]
\lipsum[25]
{\section*{Introduction}}
\sides{I am hoping to create some proper paper using this template when i do my masters.}
\lipsum
\sides{How does a para look with this on sides. For a moment i thought it is gone}
\lipsum

%\vspace{1cm}
\vfill{}
%\hrulefill

\end{document} 

enter image description here

share|improve this answer
add comment

You can use fancyhdr to place a \colorbox in the header:

enter image description here

\documentclass[10pt, a4paper]{article}
\usepackage[left=5cm,right=2.5cm,top=5cm,bottom=3cm,headheight=22pt]{geometry}% http://ctan.org/pkg/geometry
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\fancypagestyle{unique}{%
  \renewcommand{\headrulewidth}{0pt}% No header rule
  \fancyhf{}% Clear header/footer
  \fancyfoot[C]{\thepage}%
  \fancyhead[C]{%
    \colorbox{black}{\parbox{\dimexpr\textwidth-2\fboxsep}{%
      \color{white}\LARGE Effect of aspect ratio and others on others and ourselves}}%
  }%
}
\begin{document}

\thispagestyle{unique}
\lipsum[1-10]

\end{document}

You can, of course, modify the unique page style to your liking. I've only duplicated the plain page style and added your required header.

Modifications to the header could include stretching the box to span outside the margin. Here's a quick view on the header changes to incorporate it:

\fancypagestyle{unique}{%
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% No header rule
  \fancyfoot[C]{\thepage}%
  \fancyhead[C]{%
    \makebox[\textwidth]{%
      \colorbox{black}{\parbox{\dimexpr\textwidth+50pt-2\fboxsep}{%
        \color{white}\LARGE Effect of aspect ratio and others on others and ourselves}}%
  }}%
}

The above header change pushes the coloured box outward (left and right) by 25 points. It accomplishes this by placing a 50pt overset coloured box inside a centred \textwidth box. This avoids LaTeX complaining about an overfull \hbox spanning more than \textwidth.

share|improve this answer
    
Can you tell how to extend the black box even to the right and left margins at the top. –  sgp Jun 7 '12 at 0:54
    
@sgp: Added something to show how to extend the box into the margins. –  Werner Jun 7 '12 at 18:07
add comment

One:We can use the package tcolorbox by Thomas F. Sturm.

See

Make an Example and shaded box like in the book

Two: We can use the package contour

\documentclass{standalone}

\usepackage{tikz}
\usepackage[outline]{contour}
\contourlength{1.2pt}

\begin{document}

\begin{tikzpicture}[scale=2]

\draw [fill=black](0,0) rectangle (4.5,1);
\node at (0.75,0.5) {\contour{white}{\Large Text!}};
\node [fill=white,inner sep=1pt] at (2.25,0.5) {\Large Text!};
\node [fill=white,rounded corners=2pt,inner sep=1pt] at (3.75,0.5) {\Large Text!};

\end{tikzpicture}

\end{document}

enter image description here

Three: this may be useful

\documentclass{standalone}

\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=2]
\node at (5,5) (p) {B}; 
\draw (p.south) -| ++(2mm,3mm) -| (p.north);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
I have updated the question with an example. Can you suggest now how to do it? –  sgp Jun 2 '12 at 14:59
add comment

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.