free web stats

Ankur A. Kulkarni

Associate Professor and Kelkar Family Chair

Systems and Control Engineering, Centre for Machine Intelligence and Data Science, IIT Bombay Trust Lab, Koita Centre for Digital Health

Indian Institute of Technology Bombay


Indian Cooking

Cricket

Indian Classical Music

Streaming/Downloading music

Purchasing music

Learning

Ganesh Poojan

  • MP3 file with full pooja. PDF with instructions. Both in Marathi.
Latex

Numbering and lists

  • Numbering of theorems or lemma according to chapter and section. \numberwithin typically does the job. However if a theorem is mentioned before the first section begins, theorem gets numbered as, e.g., Theorem 2.0.1. Here is a way to correct that. In your document preamble (after the \newtheorem), put the following:
    \makeatletter
    \@addtoreset{lemma}{chapter}
    \makeatother
  • Automatic numbering in tables. To generate a table with numbered entries (rows, say) one typically needs to enter the numbers manually. Here's how it can be automated.
    \newcounter{rownum}
    \setcounter{rownum}{0}
    % Table
    \begin{table}[htbp]
    \caption{Table Caption}
    \begin{center}
    \begin{tabular}{|c||l|l|}
    \hline
    \textbf{\#} & \textbf{Column1} & \textbf{Column2} \\ \hline \hline
    %Increment then display the counter value
    \addtocounter{rownum}{1}\arabic{rownum}. & Row1Cell2 & Row1Cell3 \\ \hline
    \addtocounter{rownum}{1}\arabic{rownum}. & Row2Cell2 & Row2Cell3 \\ \hline
    \addtocounter{rownum}{1}\arabic{rownum}. & Row3Cell2 & Row3Cell3 \\ \hline
    \end{tabular}
    \end{center}
    \label{tablelabel}
    \end{table}%
    Clearly, one can automate this further by defining a macro for \addtocounter{rownum}{1}\arabic{rownum}.
  • Inventing one's own labels in an enumerate or itemize environment often makes the labels spill out of the left margin. Use the following to nullify this.
    \addtolength{\itemindent}{ your length }

Boxes

  • Some ways of boxing equations and 'problem' statements.
    A box with 6 arguments: (1) contents to be boxed, (2) name/tag (3) width of the box (4) spacing to the left of content (5) width of content (6) width for name. Useful for problem statements. Does not carry an equation number. Specify contents in usual text.
    \newcommand{\boxedeqnsmall}[6]{\vspace{12pt}
     \noindent\framebox[#3 \textwidth]{\begin{tabular*}{#3 \textwidth}{p{#5 \textwidth }p{#6 \textwidth }}
                                   \hspace{#4 \textwidth}  #1 & \raggedleft #2
                                    \end{tabular*}
    }\vspace{12pt}
    }

    A box with 3 arguments: (1) contents to be boxed (2) name/tag (3) width of box. This box can be labelled and can be referred to by the tag. Specify contents in math mode. Can use the tabular environment to keep content organised.
    \newcommand{\boxedeqn}[3]{\vspace{-.2in}
    \begin{center}
      \fbox{%
          \begin{minipage}{#3 \textwidth}%
          \begin{equation}#1 #2 \end{equation}%
          \end{minipage}%
        }%
        \end{center}
    }
  • A filled box is easily created using \rule by using the appropriate width and thickness. In particular a QED box most suitable to one's liking can be created by this command.
    \rule{width}{thickness}

Headers and footers

These modifications need package fancyhdr
  • Redefine \chaptermark and \sectionmark
    \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\slshape\chaptername{} \thechapter: #1}}{}}
    \renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{\slshape\thesection : #1}}}
  • Managing headers on empty pages. First redefine plain page style. Then create empty pages before new chapter.
    % Redefine plain page style
    \fancypagestyle{plain}{
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \fancyfoot[LE,RO]{\thepage}
    }
    % Code for creating empty pages
    % No headers on empty pages before new chapter
    \makeatletter
    \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}
    \thispagestyle{plain}
    \newpage
    \if@twocolumn\hbox{}\newpage\fi\fi\fi}
    \makeatother \clearpage{\pagestyle{plain}\cleardoublepage}
  • The ToC usually requires you to hard-code its header for you, but it is hard to do so. The trick is to do the following
    \tableofcontents{ put your formatting here}

  • Long chapter titles often lead to problems in the header and the ToC. Use this to give a proxy title in the ToC and header while retaining the original chapter title for the chapter.

    \chapter[short title]{long title}
  • geometry combined with headers often creates unduly large margins above chapter titles on the first page of the chapter. Pulling up the title resolves this.

    \chapter{\vspace{ distance } title}
  • Book format distinguishes between even and odd sides. It is easy to get different headers for even and odd sides in this format. But getting this in a one-sided report requires some code
    \usepackage{fancyhdr,ifthen}

    % Setup for headers and footers (fancyhdr)
    \lhead{\ifthenelse{\isodd{\value{page}}}{\rightmark}{\leftmark}}

Referencing

  • Referring back from the bibliography to the pages where the reference is cited can be done by backref or pagebackref option of hyperref. But this gives only a list of pages where the citation has occurred, following the details of the citation. A nicer way is to do the following.

    \usepackage[hyperpageref]{backref}
    \renewcommand*{\backref}[1]{}
       \renewcommand*{\backrefalt}[4]{
          \ifcase #1
             Not cited.
          \or
             {\small \it \textsf{(Cited on page #2)}}
          \else
             {\small \it \textsf{(Cited on pages #2)}}
          \fi}
  • Only initials in bibliography. One of the most painful things to do is making the bibliography consistent (with respect to use of first name or initials) by making explicit changes in the bib file. Here is a workaround that involves changing the bibliography style file to automatically pick out only initials of authors from any bib entry.
  • makebst allows one to make one's own bst file. This is useful when you have to deal with unusual referencing formats for certain journals.
  • Typically references in the list as listed as [x], where x is the reference number. If you want to change this style, say to x., you need to modify biblabel as follows.

    \makeatletter
    \renewcommand\@biblabel[1]{#1.}
    \makeatother

Graphics

Miscellaneous

Packages

  • hyperref To create hyperlinks in a document.
  • sectsty To control chapter and section title fonts and styles. Add lines etc to make them look nicer.
  • geometry To control margins
  • xspace For macros in text mode. Remove space if the macro is followed by a punctuation mark and retain if not.
  • fancyhdr Fancy headers and footers. Control positioning of chapter titles, page numbers header lines etc.