9

Please help me create the following box with the text as seen in the pic. I have written the following code and it comes out like this. But I am still not satisfied with the results and the outlook. Any help would be appreciated. Thanks in advance.

enter image description here

\documentclass[12pt]{exam}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{tcolorbox}
\usepackage{graphicx}
\usepackage[hmargin=0.8in,vmargin=0.5in]{geometry}
\usepackage{array}
\usepackage{setspace}
\newcommand*\diff{\mathop{}\!\mathrm{d}}
\newcommand*\Diff[1]{\mathop{}\!\mathrm{d^#1}}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}


\begin{document}

\begin{tcolorbox}

Write your name here\\
\begin{tabular}{|l|r|}
\hline
\scriptsize{Surname} \hspace{8cm} & \scriptsize{\hspace{4.5cm}Other Names \hspace{3cm}}\\[5mm]
\hline
\end{tabular}
\\[2mm]
\vspace{0.5in}
\begin{tabular}{lrr}
\Large{\textbf{AHS Examinations}} \hspace{6cm}& Center Number \hspace{2cm}& Candidate Number\\
\textbf{Semester 4} \hspace{4cm}&\begin{tabular}{|c|c|c|c|c|}\hline & & & & \\ \hline\end{tabular}  &\hspace{3.5cm} \begin{tabular}{|c|c|c|c|c|}\hline & & & \\ \hline\end{tabular}\\
\textbf{Advanced Level} & &  
\end{tabular}


\begin{tabular}{|l|c|}
\hline

\huge{\textbf{Core Mathematics C12}} &\\
\textbf{Advanced Subsidiary}  & \\[5mm]

\hline
April, 2017 \hspace{11cm} & \scriptsize{Paper Reference} \\
\textbf{Time: 1 hours 30 minutes} & \textbf{WMA01/01}\\
\hline
\end{tabular}
\\\\
\fbox{\parbox{13.5cm}{\textbf{You must have:}\\
Mathematical Formulae and Statistical Tables (Blue) \\}} \fbox{\parbox{2cm}{\scriptsize{Total Marks \hspace{2cm}}\\\\\\}}
\end{tcolorbox}

\end{document}
  • 1
    Welcome to TeX.SX! BTW, size commands like \scriptsize or \huge do not have arguments. The scope can be limited by curly braces as group braces {\scriptsize ...} instead of argument braces. The group around a table cell is not needed, because LaTeX table cells have an implicit group, e.g.: ... & \scriptsize Paper Reference \\ – Heiko Oberdiek May 07 '17 at 06:06
  • Could you please give some feedback regarding the solution? –  May 10 '17 at 17:58
  • The solution when compiled gave the perfect correct box i am looking for. Working with tables is tricky for me though since i am not a computer science person in the first place but new to typsetting latex. I am enjoying latex now. Anyway thanks for the quick response and do appreciate your superb answer. – Mohamed Aamir May 18 '17 at 02:23
  • 1
    @christian Hupfer: accepted. – Mohamed Aamir May 20 '17 at 04:38

1 Answers1

14

In order to achieve such a complex layout, many tricks from tcolorbox are needed:

  • tcbraster
  • raster multicolumn
  • overlay with drawing the shifted vertical line to the segmentation line node
  • using a special segmentation style
  • sidebyside options

  • Using the tabularx key of tcolorbox and some tricks to get the tables with rounded corners.

  • A style for boxes that do not have a frame, called notcb

\documentclass[12pt]{exam}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{array}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{graphicx}
\usepackage[hmargin=0.8in,vmargin=0.5in]{geometry}
\usepackage{array}
\usepackage{setspace}
\newcommand*\diff{\mathop{}\!\mathrm{d}}
\newcommand*\Diff[1]{\mathop{}\!\mathrm{d^#1}}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}

% A style for tcolorbox without frame etc. "notcb"
\tcbset{notcb/.style={enhanced jigsaw, colback=white, coltitle=black,sharp corners, boxrule=0pt}}

% Style for the number tables
\tcbset{tabularheader/.style={arc=2pt,natural height,notcb,boxsep=0pt,left=0pt,colbacktitle=white,rounded corners=all,enhanced jigsaw,coltitle=black,tabularx={*{4}{Y|}Y},boxrule=1pt,attach boxed title to top left, boxed title style={enhanced jigsaw,sharp corners,left=0pt,boxrule=0pt}}}

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}


\begin{tcolorbox}[colback=white]



Write your name here
\begin{tcbraster}[raster columns=1, raster column skip=0pt, raster equal height,colback=white,before skip=0pt]
  \begin{tcolorbox}[coltitle=black,enhanced jigsaw,boxrule=0.5pt,boxsep=0.5pt,segmentation style={solid,black,line width=0.5pt},sidebyside,
    righthand width=4cm,fontupper=\normalsize,
    ]
    Surname
    \bigskip
    \tcblower
    Other names
    \bigskip
  \end{tcolorbox}
\end{tcbraster}
\begin{tcbraster}[raster columns=3,raster equal height]
  \begin{tcolorbox}[notcb,fontupper=\bfseries\raggedright]
    {\Large \vphantom{y}AHS Examinations}

    Semester 4

    Advanced Level

    \end{tcolorbox}
    \begin{tcolorbox}[tabularheader,title={Center Number}]
      & & & & \tabularnewline
    \end{tcolorbox}
    \begin{tcolorbox}[tabularheader,title={Candidate Number}]
      & & & & \\
    \end{tcolorbox}
  \end{tcbraster}
  \begin{tcolorbox}[enhanced jigsaw,fontupper=\bfseries,colback=white,segmentation style={solid,tcbcol@frame,line width=2pt},underlay={
    \draw[tcbcol@frame,line width=1pt] ([xshift={5cm}]frame.south) -- ([xshift={5cm}]segmentation.center);
  }
  ]
  {\Large Core Mathematics C12}

  Advanced Subsidiary
  \bigskip
  \tcblower
  Wednesday  April 2017 \hfill {\raggedright \scriptsize Paper Reference}

  Time 1 hour 30 minutes \hfill\raggedright WMA01/01
\end{tcolorbox}
\begin{tcbraster}[raster columns=6,raster equal height,boxsep=0.5pt]
\begin{tcolorbox}[colback=white,raster multicolumn=5]
  {\large \textbf{You must have:} }

  Mathematical Formulae and Statistical Tables (Blue)
  \bigskip
\end{tcolorbox}
\begin{tcolorbox}[colback=white,left=2pt,right=2pt]
  Total Marks

  \bigskip
\end{tcolorbox}
\end{tcbraster}
\end{tcolorbox}

\end{document}

\begin{tcolorbox}


Write your name here\\
\begin{tabular}{|l|r|}
\hline
\scriptsize{Surname} \hspace{8cm} & \scriptsize{\hspace{4.5cm}Other Names \hspace{3cm}}\\[5mm]
\hline
\end{tabular}
\\[2mm]
\vspace{0.5in}
\begin{tabular}{lrr}
\Large{\textbf{AHS Examinations}} \hspace{6cm}& Center Number \hspace{2cm}& Candidate Number\\
\textbf{Semester 4} \hspace{4cm}&\begin{tabular}{|c|c|c|c|c|}\hline & & & & \\ \hline\end{tabular}  &\hspace{3.5cm} \begin{tabular}{|c|c|c|c|c|}\hline & & & \\ \hline\end{tabular}\\
\textbf{Advanced Level} & &  
\end{tabular}


\begin{tabular}{|l|c|}
\hline

\huge{\textbf{Core Mathematics C12}} &\\
\textbf{Advanced Subsidiary}  & \\[5mm]

\hline
April, 2017 \hspace{11cm} & \scriptsize{Paper Reference} \\
\textbf{Time: 1 hours 30 minutes} & \textbf{WMA01/01}\\
\hline
\end{tabular}
\\\\
\fbox{\parbox{13.5cm}{\textbf{You must have:}\\
Mathematical Formulae and Statistical Tables (Blue) \\}} \fbox{\parbox{2cm}{\scriptsize{Total Marks \hspace{2cm}}\\\\\\}}
\end{tcolorbox}


\end{document}

enter image description here

  • @barbarabeeton: Thanks, it is \raggedright now –  May 07 '17 at 08:47
  • hmmm. baselines a bit tight. might want to add a \vphantom{y} at the beginning. (don't need a \strut since you only want to affect the bottom of the first line.) – barbara beeton May 07 '17 at 08:53