Friday, April 12, 2013

table with customised width of columns.

using p{.} in place of c/l, we can specify column width, as given in example below:


\begin{table}[!t]
\scriptsize
    \centering
    \caption{Converged Degrees}
   \begin{tabular}{|p{1.2cm}|l|l|p{1.4cm}|p{1.2cm}|p{1.5cm}|}
     \hline
         Model & $D1$  & $D2$  & D3  &  D4 & D5   \\ \hline
        M1 &0.240156 &0.556627 &2.134504 &0.484830 &224.384399 \\ \hline
M2 &0.442761 &0.675242 &0.339483 &0.300454 &382.939148 \\ \hline
M3 &0.556715 &0.825190 &0.002302 &1.000000 &60.705791 \\ \hline
    \end{tabular}
    \label{fig:Degress}
\end{table}

Thursday, April 11, 2013

an example showing how to merge multiple rows of a column using \multirow


\begin{table}[!h]
\scriptsize
    \centering
\caption{CV Results}
\begin{tabular}{c|c|c|c|c}
\hline
\textbf{Mobility Model} & \textbf{CV} & \textbf{Number of files}  & \textbf{Success}  & \textbf{Success Percentage}   \\
\hline
\multirow{3}{*}{GM}
      & 2 &225 &124 &55\\
      & 4 &117 &68         &58\\
      & 10 &45         &29         &64 \\ \hline
\multirow{3}{*}{RD}
      & 2 &405 &57  &14\\
      & 4 &207 &37         &18\\
      & 10 &90         &13         &14 \\ \hline
\end{tabular}
\label{tab:ResultsTraining}
\end{table}

an MWE for a thesis report


\documentclass[a4paper,12pt]{report}
\usepackage{multirow}
\let\proof\relax
\let\endproof\relax
%\usepackage{pstricks}
\usepackage{amsmath, amssymb, amsthm,mathtools} % AMS packages
\usepackage{graphicx,color}
\usepackage{epsfig}
\usepackage{fixltx2e}
\usepackage{graphics}  
%\usepackage{sidecap}
\usepackage{marvosym}
\usepackage{setspace}
\usepackage{textcomp}
\usepackage{tabularx}
\usepackage[belowskip=-5pt,aboveskip=10pt]{caption}
%\usepackage{subcaption}
%\usepackage{layouts}
\usepackage{cite, url}
\usepackage{tabbing}
\usepackage{fancyvrb}
\usepackage{float}
\usepackage{textcomp}
\usepackage{array}
\usepackage{subfigure}
\usepackage{epsfig}
\usepackage{comment}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{xcolor}
\usepackage{setspace}
\setstretch{1.2}
%\usepackage{pxfonts}
%\usepackage{titlesec}
    % Packages for graphics and color
\usepackage[left=1.3in, right=1in, top=1in, bottom=1in, includefoot, headheight=13.6pt]{geometry}
%\usepackage[T1]{fontenc}
\usepackage{floatpag}  %to disable page numbers in pgs where figs cover whole pg
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
%\usepackage{wasysym}
%\usepackage{fancyhdr}
%\pagestyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

%\newenvironment{proof}[1][Proof]{\begin{trivlist}
%\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{example}[1][Example]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{remark}[1][Remark]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

\newcommand\Signature[4]{\par\bigskip
  \setlength\tabcolsep{0pt}
  \begin{tabular}{@{\hspace{.05\textwidth}}>{\centering\arraybackslash}p{.4\textwidth}
      @{\hspace*{.1\textwidth}}>{\centering\arraybackslash}p{.4\textwidth}@{\hspace{.05\textwidth}}}
  \multicolumn{2}{c}{#1} \\[5ex]
  \rule{.4\textwidth}{0.4pt} & \rule{.4\textwidth}{0.4pt} \\
  #2 & #3 \\[5ex]
  \multicolumn{2}{c}{\rule{.4\textwidth}{0.4pt}} \\
  \multicolumn{2}{c}{#4}
\end{tabular}
\par
}
%-----------------------------------
\newcommand{\superscript}[1]{\ensuremath{^{\textrm{#1}}}}
\newcommand{\subscript}[1]{\ensuremath{_{\textrm{#1}}}}
\newcommand{\mlt}[1]{\mathbf{#1}} %matrix bold for Latin symbols
\newcommand{\mgr}[1]{\boldsymbol{#1}}%matrix bold for Greek symbols
\newcommand{\ksp}{\vspace{0.1in}}
%--------------------------------------
\begin{document}

\pagenumbering{roman}
\thispagestyle{empty}
\vspace{1cm}

\begin{center}
% \pagestyle{myheadings}
{\LARGE{\bf  PROJECT TITLE }\LARGE\\ }
\vspace{1.4in}

{\bf \emph{YOUR NAME}}\\
{\bf Roll No: 11}\\
 \vspace{1.2 in}
 \begin{figure}[h]
   \centering
     \includegraphics[height=3cm,width=3cm]{images/iitlogo.eps}
   \end{figure}
\begin{center}
   {{\bf SCHOOL OF XXXXX} \\
       {\bf COLLEGE}\\
       {\bf STATE, COUNTRY}\\
%{\bf APR 2011}
   }
 \end{center}
\end{center}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\thispagestyle{empty}
\begin{center}
{\LARGE{\bf PROJECT TITLE }\LARGE\\}
  \vspace{0.3 in}
  {\tt }
\begin{center}
{
{\bf \emph{Thesis submitted to}}\\
  {\bf \emph{COLLEGE}}\\
{\bf \emph{for the partial fulfillment of the requirements} }\\
{\bf \emph{for the award of the degree of}}\\
}
\end{center}
    \vskip 0.5 cm
  {\bf Master of Technology}\\
  \vskip 0.1 cm
  { in}
  \vskip 0.1 cm
  {\bf Information Technology}\\
  \vskip 0.2 cm
  {by}  \\
  %\vspace{0.7 cm}
%  {\tt }
  {\Large {\bfYOUR NAME}}\\
 % \vskip 0.3 cm
  {{(\bf Roll No.: 11)}}
  \vskip 0.7 cm
  {\bf \emph{Under the guidance of} } \\
 % \vskip 0.3 cm
  {{\bf Dr. DDDDD}}
  \vspace{0.4 cm}
  \begin{figure}[h]
    \centering
      \includegraphics[height=2.5cm,width=2.5cm]{images/iitlogo.eps}
    \end{figure}
  \begin{center}
    {{\bf SCHOOL XXXX} \\
       {\bf COLLEGE}\\
       {\bf STATE, COUNTRY}\\
{\bf APR 2011}
   }
  \end{center}
\end{center}
\newpage

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%APPROVAL  PAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\thispagestyle{empty}
\begin{center}
{\LARGE{\bfPROJECT TITLE }\LARGE\\}
  \vspace{0.3 in}
  {\tt }
\begin{center}
{
{\bf \emph{Thesis submitted by}}\\
}
\end{center}
    \vskip 0.5 cm
    {\Large {\bf YOUR NAME}}\\
 % \vskip 0.3 cm
  {{(\bf Roll No.: 11)}}
  \vskip 0.7 cm
{\bf \emph{Approved by}}
\vskip 1.7 cm
\begin{Verbatim}[fontfamily=tt,fontseries=b]
Dr. AAA                               Dr. BBB
 (Supervisor)                             (Head of the Department)
\end{Verbatim}
 \vspace{0.4 cm}
  \begin{figure}[h]
    \centering
      \includegraphics[height=2.5cm,width=2.5cm]{images/iitlogo.eps}
    \end{figure}
   \begin{center}
    {{\bf SCHOOL XXXX} \\
        {\bf COLLEGE}\\
        {\bf STATE, COUNTRY}\\
 {\bf APR 2011}
    }
  \end{center}
\end{center}
\newpage

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\include{Declaration/declaration}
\include{Certificate/certificate}
\include{Acknowledgement/acknowledgement}
\include{Abstract/abstract}
\newpage
\tableofcontents
\listoffigures
\listoftables
\listofalgorithms
\newpage
\pagenumbering{arabic}

\include{Introduction/introduction}
\include{Chapter1/chapter1}
\include{Chapter2/chapter2}
\include{Chapter3/chapter3}
\include{Chapter4/chapter4}
\include{Conclusions/conclusions}

%============================ References ==============================

\bibliographystyle{IEEEtran}
\bibliography{../bblfile}

\end{document}

Placing subtables and subfigures in Latex.

One can experiment with placing subtables and subfigures with their lists also generated using subfloat. The code snippet is:


\documentclass[11pt, a4paper, draft]{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\listoftables
\listoffigures
\section{Example with 3 "sub" tables}
\begin{table}[ht]
\centering
\subfloat[Subtable 1 list of tables text][Subtable 1 caption]{
\begin{tabular}{l|ccc}
& 1 & 2 & 3\\
\hline
1 & A & B & C\\
2 & D & E & F\\
\end{tabular}}
\\
\subfloat[Subtable 2 list of tables text][Subtable 2 caption]{
\begin{tabular}{l|ccc}
& 1 & 2 & 3\\
\hline
1 & A & B & C\\
2 & D & E & F\\
\end{tabular}}
\\
\subfloat[Subtable 3 list of tables text][Subtable 3 caption]{
\begin{tabular}{l|ccc}
& 1 & 2 & 3\\
\hline
1 & A & B & C\\
2 & D & E & F\\
\end{tabular}}
\caption{This is a table containing several subtables.}
\end{table}
\clearpage
\section{Example with 4 "sub" figures 2x2}
\begin{figure}[h]
\centering
\subfloat[Subfigure 1 list of figures text][Subfigure 1 caption]{
\includegraphics[width=0.4\textwidth]{LA}
\label{fig:subfig1}}
\qquad
\subfloat[Subfigure 2 list of figures text][Subfigure 2 caption]{
\includegraphics[width=0.4\textwidth]{LA}
\label{fig:subfig2}}
\subfloat[Subfigure 3 list of figures text][Subfigure 3 caption]{
\includegraphics[width=0.4\textwidth]{LA}
\label{fig:subfig3}}
\qquad
\subfloat[Subfigure 4 list of figures text][Subfigure 4 caption]{
\includegraphics[width=0.4\textwidth]{LA}
\label{fig:subfig4}}
\caption{This is a figure containing several subfigures.}
\label{fig:globfig}
\end{figure}
In the text, you can refer to subfigures of figure \ref{fig:globfig} as \ref{fig:subfig1}, \ref{fig:subfig2}, \ref{fig:subfig3} and \ref{fig:subfig4} and to the sub-index as \subref{fig:subfig1}, \subref{fig:subfig2}, \subref{fig:subfig3} and \subref{fig:subfig4}.
\end{document}