Pakistan Flag Dimensions


With 14 August 2016 coming tomorrow I am studying the dimensions of the Pakistan flag as recommended in [3]. The results are shown in above figure. All dimensions are with reference to the height of the flag “H”. Width of the flag is one and half times H, shown as “3H/2” in dimension. The white strip is 1/4th of the total width that translates to 3/8th of height. The outer arc of crescent is a circle with center at center of the green portion with radius thirty percent of flag height. The five pointed star is circumscribed by circle of radius 1/10 H and touches the first circle from inside towards the top right corner. One point of the star is aligned towards top right corner. The inner arc radius is 11/40 times the height with center on off-diagonal line at a distance of 13/20 H from  top right corner. The flag is colored in Pakistan green having standard RGB values (red = 0, green = 102, blue = 0) or with hex triplet #006600 or the HSV value = (h = 120, s = 100, v = 40). The left strip, the star and  the crescent are painted in white. The flag is supported from left white side. The flag is not to be flown vertically. The below figure shows an example with height taken as 20.


Programmed tikz to draw the flag in latex.

\definecolor{green}{RGB}{0, 100, 0}
% Use wikipedia's dimensions

  \fill[green] rectangle (12, 8);%G=8, L=12, L=1.5 G
    \fill[white] (.01,.01) rectangle (2.98, 8);%G=8, L=12, L=1.5 G

   \fill[white] (7.5,4) circle (2);
   \fill[green] (7.9,4.4) circle (1.6);
    \node[star,fill=white, minimum size=1.7cm, rotate=25, star point ratio=2.617,inner sep=0pt] at (8.9,5.5) {};


National Assembly Passed the Design on 11 August 1947

That this assembly resolves that the national flag of the federation of Pakistan be of the following description.

“A dark green rectangular flag in the proportion of length and width 3:2 with a white vertical bar at the mast, the green portion bearing a white crescent in the centre and a five-pointed white heraldic star. The size of the white portion being one-fourth the size of the flag, nearest the mast, the remainder three-fourths being dark green. the dimensions of the crescent and star are obtained as follows:

“Draw the diagonal from the top right hand corner to the bottom left corner of the green portion. On this diagonal establish two points ‘A’ and ‘B’. Point ‘A’ at a distance equidistant from top right and bottom left hand corners of the green portion, i.e. the centre of the green portion. Point ‘B’ at a distance from the top right hand corner equal to 13/20th the width of the flag. With centre point ‘A’ and radius 1.1/4th the width of the flag describe a second arc. The enclosures made by these two arcs form the crescent. The dimensions of the five-pointed white heraldic star are determined by drawing a circle 1/10th the width of the flag. The circle surrounds the five points of the heraldic star. The star lies with one point on the diagonal at a point where the larger arc of the crescent, if completed, cuts the diagonal.”

Flag Construction References:




Latex UMT Exam Template

UMT Exam
Following is an exam template that was created for University of Management and Technology Lahore, typeset using pdflatex and Philip Hirschhorn's exam.cls:
% Exam Template for University of Management and Technology Lahore
% Author: Abu Bakar Siddique
% The folder of this tex should also contains UMTLogo.jpg and exam.cls
% Adapted From:
% Exam Template for UMTYMP and Math Department courses
% Using Philip Hirschhorn's exam.cls:
% run pdflatex on a finished exam at least three times to do the grading table on front page.

\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\RequirePackage{tikz, pgflibraryplotmarks}
    treenode/.style = {circle, draw=black, align=center,
                          minimum size=1cm, anchor=center},

%            E X A M   I N F O R M A T I O N

\newcommand{\courseTitle}{Data Structures And Algorithms}
\newcommand{\examDate}{April 09, 2013}
\newcommand{\examType}{Mid Term}
\newcommand{\RP}{Mr. Saleem Ata (Sec A \& E), Abu Bakar Siddique (Sec  B, C \& D)}
\newcommand{\semester}{Spring 2013}
\newcommand{\timeAllowed}{30 Minutes}


% \onehalfspacing
% \doublespacing
% For an exam, single spacing is most appropriate

% For an exam, we generally want to turn off paragraph indentation
%\parindent 3ex

\title{\vspace{-7ex} University of Management \& Technology\vspace{-1ex}}
\author{Department of Electrical Engineering


\begin{tabular}{l c}
\multirow{4}{*}{ \includegraphics[width=.75in]{UMTLogo.jpg} }& \\
& {\Large  \textbf{University of Management \& Technology}}\\
&\large \textbf{School of Engineering}\\
& \textbf{Department of Electrical Engineering}\\ %[\rowSpace]

%        Header
\runningheader{ \textbf{Student ID:}}{\includegraphics[scale=.1]{UMTLogo.jpg}}{\textbf{Section:}\quad}
\runningfooter{}{Page \thepage\ of \numpages}{}

\begin{tabular}{p{1.5in} p{2in} p{.05in} p{1.2in} p{1in}}

\textbf{Student ID}&\hrule && \textbf{Section} & \hrule \\ [\rowSpace]
\textbf{Student Name}&\hrule && \textbf{Semester}& \semester\\ [\rowSpace]
\textbf{Student Signature}&\hrule&&&\\ [\rowSpace]
\textbf{Course Code}&\courseCode && \textbf{Academic Year} & \academicYear\\
\textbf{Course Title}& \courseTitle && \textbf{Time Allowed} & \timeAllowed\\
\textbf{Exam Date}& \examDate && \textbf{Total Marks}& \totalMarks\\
\textbf{Exam}& \examType && & \\
\textbf{Resource Person(s)} & \multicolumn{4}{p{4.5in}}{\RP}\\
\emph{The instructions below must be followed strictly. Failure to do so can result in serious grade loss.}\\
 \textbf{You must}
  \item Keep your eyes on your own paper.
  \item Switch off your mobile phones completely.

\textbf{Specific instructions}
\item \textbf{Calculator Allowed, Closed Book, Closed Notes.}
\item \textbf{No extra sheet} will be given. Use the available space wisely.
\item \textbf{Use a blue or black} ball point or pen. Please do not use lead pencils.
\item \textbf{Provide final answers} in the space provided.You may use back blank sheets for rough work.

\textbf{Certificate to be filled at the time of exam}

I have counted all \numpages\ pages in this exam and no page is missing. \hfill \textbf{Student Signature}

\addpoints % required here by exam.cls, even though questions haven't started yet.
\gradetable[h][questions]%[pages]  % Use [pages] to have grading table by page instead of question


\textbf{Certificate to be filled during paper viewing}

I have reviewed my paper and all \numquestions\ questions have been marked with\\ no
 part left unmarked. Counting is also correct. \hfill \textbf{Student Signature}

\newpage % End of cover page

%            Q U E S T I O N S
% See for full documentation, but the questions
% below give an idea of how to write questions [with parts] and have the points
% tracked automatically on the cover page.


% Basic question
%\question[10] Differentiate $f(x)=x^2$ with respect to $x$.

\question[3] Write Pre-Order, In-Order and Post-Order traversals of following tree:

    \begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 5cm/#1,
    level distance = 1.5cm},scale=0.6, transform shape]

    \node [treenode] {7}
        node [treenode] {5}
            node [treenode] {3}
            child{ node [treenode] {1} }
            child{ node [treenode] {4} }
        child{ node [treenode] {6} }
        node [treenode] {8}
        	node [treenode] {1}
            node [treenode] {2}
            child{ node [treenode] {7} }
            child{ node [treenode] {9} }

\question[2] A Binary Tree has 37 nodes. What is the minimum height of the tree that can take all of these nodes? Take height of a single node tree as 1.

\question[3] Make structure of a binary tree that has following Pre-Order and In-Order traversals:
\item[Pre-Order:] A, B, D, E, F, G, C
\item[In-Order:] D, B, F, E, G, A, C

\question[1] How many comparisons would take place when finding a value in a sorted list of 1024 entries using binary search algorithm? (2 Marks)

\question[4] Construct binary search tree when values are inserted in following order:\\
 $\longrightarrow$ 9, 13, 12, 1, 7, 25, 4, 19, 3, 23, 11, 4, 27,6

\question[2] Starting with empty stack, what would be the contents of the stack after following operations are performed.Draw the stack after the following operations
\item Push(56)
\item Push(92)
\item Push(7)
\item Pop()
\item Push(5)
\item Pop()


% Question with parts
%\question Consider the function $f(x)=x^2$.
%\part[5] Find $f'(x)$ using the limit definition of derivative.
%\part[5] Find the line tangent to the graph of $y=f(x)$ at the point where $x=2$.

% If you want the total number of points for a question displayed at the top,
% as well as the number of points for each part, then you must turn off the point-counter
% or they will be double counted.
%\question[10] Consider the function $f(x)=x^3$.
%\noaddpoints % If you remove this line, the grading table will show 20 points for this problem.
%\part[5] Find $f'(x)$ using the limit definition of derivative.
%\part[5] Find the line tangent to the graph of $y=f(x)$ at the point where $x=2$.


English to Urdu Dictionary Ebook LaTeX Source

PDF Ebook Download: English2UrduDict


Here is the code used for creating the English to Urdu dictionary.pdf eBook. It uses XeLaTeX, a unicode extension to LaTeX typesetting system, supporting true type fonts with *.ttf extension. Here is the screen shot from above pdf file.


The code has provision to change the page dimensions according to ones liking without playing havoc with formatting.  Initially the design was made using the tabularx environment. It offers support for bidirectional required to combine the right to left Urdu text with left to right English translations.  After deciding on the page format, when the dictionary file was populated with more entries, it transpired that tabularx won’t support the tables longer than one page. Second search brought out that longtable environment supports the multi-page tables. Longtable, however, messed up the whole bidirectional design, doing strange things to both Urdu and English text. Later it was found that bidirectional package has some issues with longtable. Therefore the “\beginL” and “\endL” tags were used to stabilize the English text. After fidgeting with \LR and \RL , the primary language of the document had to be changed to Urdu. It is easier to edit tags surrounding  the English text  in Unicode text editors and avoids frequent switching of the typing language between  Urdu for text editing and English for tags.



% !TeX program = xelatex
\usepackage[paperwidth=441pt, paperheight=666pt, textwidth=400pt,textheight=550pt]{geometry}

%\usepackage[paperwidth=441pt, paperheight=200pt, textwidth=400pt,textheight=100pt]{geometry}

\rhead{انگریزی اردو لغت}
\lfoot{ \LaTeX ٹائپ سیٹ  }
\title{انگریزی اردو لغت}
\usepackage[table]{xcolor}    % loads also »colortbl«


\newfontfamily\urdufont[Script=Arabic]{Jameel Noori Kasheeda}
\newfontfamily{\englishfont}[Mapping=tex-text, Scale=1, Script=Latin, Color=gray]{Times New Roman}
\newfontfamily{\entryfont}[Mapping=tex-text, Scale=1, Script=Latin, Color=black]{Times New Roman}


\newcolumntype{A}{>{\hsize=2  \hsize \raggedleft  \urdufont    \setRL} X}
\newcolumntype{B}{>{\hsize=.5 \hsize \raggedright \englishfont \setLR} X}
\newcolumntype{C}{>{\hsize=1.5\hsize \raggedright \entryfont   \setLR} X}
\newcolumntype{D}{>{\hsize=0  \hsize \raggedright \englishfont       } X}

\newcommand{\Lt}[1]{\beginL #1\endL} % Left


Note: > symbol is displayed as &gt in browser page rendering. Probably it is a bug of

tag used for code highlighting in wordpress. The dictionary text is defined in the following dict.tex file.

اردو ترجمہ &Classification &\Lt{ English} & \\
 فرسٹ ريٹ ۔  & Adjective, Name  &\Lt{ A} & \\
 انگریزی حروفِ تہجِّی کا پہلا حرف ۔ ایک & Noun, Adjective  &\Lt{ A} & \\
 انگریزی حروف تہجی کا ایک اہم لفظ ۔  & Noun  &\Lt{ A} & \\
 انگریزی حروف تہجی کا پہلا حرف ۔ اُردو میں اِس کے لئے الف اِستعمال ہوتا ہے ۔  & Latin Law  &\Lt{ A} & \\
 آرگون گیس کی کیمیائی علامت ۔  & Noun  &\Lt{ A} & \\
 حَضرت ہارُون علیہ الاسلام ، بنی اِسرائیل کے دُوسرے نبی سمجھے جاتے ہیں کیُونکہ خُدا تعالے۱ نے اُن کو مُوسے۱ علیہ الاسلام کا مددگار بنایا۔  آپ اپنے بھائی حضرتِ مُوسے۱ سے تین سال بڑے تھے اور ۱۵۲۳ ق م میں مِصر میں پیدا ہُوئے۔  آپکا ذِکر قُرانِ پاک میں  اور بائیبل مُقَدّس ہر دو جگہ پر ،  حَضرتِ مُوسے۱ علیہ الاسلام کے ساتھ ساتھ آتا ہے۔ سُورۃ اَلقصص ، طَہَ ، اور اَلاعراف میں ، اور تُورات ( بائیبل مُقَدّس ) میں پیدائیش ، خرُوج ، احبار اور گِنتی کی کتابوں ۔  آپ نے ۱۲۳ برس کی عُمر میں کوہِ ہُور کی چوٹی پر  وفات پائی ۔  & Noun, Name, Holy Quranic, Holy Biblical  &\Lt{ Aaron (Hazrat Haroon) P. B. U. H.} & \\
 اے ۔ اے ۔ آر ۔ کل جوکھم کا بیمہ ۔ & Noun  &\Lt{ A.A.R} & \\
 اے ۔ بی ۔ سی ممالک ۔ & Noun  &\Lt{ A.B.C Countries} & \\
 سُوَرۃ ا لَکَوثُرِ ، قُرانِ پاک کی سُورۃ نمبر ۱۰۸ ہے اورتیسویں سپارے میں شامل ہے۔  اس سُورۃ کی وجہ تسمیہ سُورۃ ھَذا کی پہلی آیت کی مُناسبت سے ہے۔  سُورۃ کا نفسِ مضُون  ، لگن اور قُربانی کے ذریعے رُوحانی دولت کا حصُول ہے اور  اللہ اور اُسکے رسُول صلی اللہ علیہ وسلم سے نفرت کرنے والا رُوحانی اجر کھو بَیٹھتا ہے۔  یہ سُورۃ اِبتدائی مکّی سُورتوں میں شامل ہے اور  تین آیات پر مُشتمل ہے۔ & Noun, Name, Holy Quranic  &\Lt{ Abundance ( Al-Kauther )} & \\
  کم مشق ۔ &   &\Lt{ A Back Hand That Is Out} & \\
 مویشی چور ۔ عادی سارق مویشیاں ۔ مویشیوں کا گلہ سرقہ کی نیَّت سے ہانک لے جانے والا ۔ & Noun  &\Lt{ A Bactor} & \\
 آغاز بد انجام بد ۔  & Idiom  &\Lt{ A Bad Beginning Makes A Bad Ending} & \\
 خالی میدان سے جھاڑی ہی بھلی ۔ پہاڑ نہ ہو تو تِنکے کی اوٹ بھلی ۔  & Idiom  &\Lt{ A Bad Bush Is Better Than The Open Field} & \\

References and Credits

Extended Pascal Triangles


What is Extended Binomial Triangle?

The Pascal’s Triangle lists the Binomial Coefficients. The expansion (1+x)^n = \binom{n}{0} + \binom{n}{1} x^1+\cdots +\binom{n}{i} x^i + \cdots + \binom{n}{n}x^n has the coefficients of x^i‘s listed in the nth row of Pascal’s Triangle. The Extended Pascal’s Triangle is the expansion of (1+x+x^2+\cdots+x^l)^n = \binom{n}{0}_l  + \binom{n}{1}_l x + \cdots + \binom{n}{ln}_l x^{ln} .

Intuitively if we have l-faced dice with face values \{0,1,2,\cdots,l\} , the nth row of Extend Pascal’s Triangle lists the \binom{n}{i}_l number of ways to get the sum i, when n such dice are thrown.

It is easy to observe that maximum value in a row is found at index \lceil nl/2\rceil. A formula by Eger [1] gives this maximum value as function of l and n as  \binom{n}{nl/2}_l = \frac{(q+1)^n}{\sqrt{( 2 \pi n q (q+2)/12)}}  .

What is Here?

Here is a Latex + Tikz + Lua script to draw the Extended Pascal’s triangle. Apart from the famous triangle where each entry in a row is the sum of two overhead entries in upper row, In Extended Pascal’s Triangle there can be any number of elements that sum to give an entry in next row. Above picture uses 4 such elements.

How it Started?

One publication required to draw the extended Pascal Triangle. Previously I did it with tables in latex code. This time I learned some Tikz and Lua scripting to automatically draw the figure.

The Source Code

% Author : Abu Bakar Siddique (14-Oct-2015)
% Credits : It started from Paul Gaborit's binomial Pascal triangle
% License: Creative Commons attribution license.
% Title : Extended Pascal's Triangle
% Information: nth row in usual Pascal triangle gives coefficients
% of x^k in expansion of (1+x)^n. My extended pascal triangle
% for trinomial gives coefficients of x^k in expansion
% of (1+x+x^2)^n . The constant \nomialVal{2} determines
% the order of base polynomial.

% \def\vRatio{3} % Vertical Ratio: Increase to expand vertically
% \def\hRatio{1} % Horizontal Ratio: Increase to expand horizontally
% \def\nomialVal{4} % {2} for binomial, {3} for trinomial
% \def\numRows{5} %{5} 5 means rows in the extended pascal triangle

\documentclass[crop,tikz]{standalone}% 'crop' is the default for v1.0, before it was 'preview'

  \def\vRatio{3} % Vertical Ratio: Increase to expand vertically
  \def\hRatio{1} % Horizontal Ratio: Increase to expand horizontally
  \def\nomialVal{4} % {2} for binomial, {3} for trinomial
  \def\numRows{5} %{5} 5 means rows in the extended pascal triangle

  \draw (\ncol,1) -- +(2,2);
  % some colors

%  \colorlet{even}{blue!127!white}
  % some styles
      text width=25mm,
      minimum height=5mm,
      inner sep=.7mm,
      outer sep=0mm,
      text centered,
      line width=.25mm,
      top color=#1!5,
      bottom color=#1!40,
      shading angle=0,
      rounded corners=2.3mm,
      drop shadow={fill=#1!40!gray,fill opacity=.8},
    link/.style={-latex,links,line width=.3mm},
  % Pascal's triangle
  % row #0 => value is 1

  % Draw nodes: p-0-0 is first node (0th row and 0th column)
  \foreach \row in {0,...,\numRows} {
    \pgfmathtruncatemacro{\eCol}{\row*(\nomialVal-1) )} //eCol = row * (nomial-1)
    \foreach \col in {0,...,\eCol} {
      \coordinate (pos) at ({-\row*(\nomialVal-1)/2*\hRatio+\col*\hRatio}, -\row*\vRatio);
      \node[box=even,label={}] (p-\row-\col) at (pos)
      	  {\directlua{tex.print("" .. multinom(\row,\col,\nomialVal))}};

  % Draw arrows from each node to "nomialVal" nodes in next row
  \foreach \row in {0,...,\numRows} {
    \pgfmathtruncatemacro{\eCol}{\row*(\nomialVal-1) )} //eCol = row * (nomial-1)
    \foreach \col in {0,...,\eCol} {
	  \foreach \arrow in {1,...,\nomialVal} {
		\ifnum \row<\numRows
		  \draw[link] (p-\row-\col) -- (p-\nrow-\ncol);

    % filling and drawing with the same color to enlarge background
    \path[draw=back,fill=back,line width=5mm,rounded corners=2.5mm]
    (  p-0-0.north west) -- (  p-0-0.north east) --
    (p-\numRows-\ncol.north east) -- (p-\numRows-\ncol.south east) --
    ( p-\numRows-0.south west) -- ( p-\numRows-0.north west) --



The above code makes use of following lualatex functions and these can be added on top of the same latex file.

  function factorial (f)
    if f < 2 then  return 1 else  return f*factorial(f-1) end

  function nchoosek(n, k)
    if (k>=0 and k<=n) then
      y = (factorial(n) / (factorial(n-k) * factorial(k)) )
      if(k==n and k<0) then y=1  else y=0  end
    return round(y)

  function round(num, idp)
    local mult = 10^(idp or 0)
    return math.floor(num * mult + 0.5) / mult

  function multinom(n,r,s)
    r = n+r;
    for k=0,math.floor((r-n)/s),1 do
      sum = sum + ((-1)^k * nchoosek(n,k)*nchoosek(r-s*k-1,n-1));
    return round(sum,1)
Binomial Pascal Triangle with 25 Rows (Click for Enlarged View)
Binomial Pascal Triangle with 25 Rows

1. S. Eger, Stirling’s approximation for central extended binomial coefficients, The American Mathematical Monthly 121 (2014), 344–349.

2. Stack exchange posts that shows number of ways a Pascal's Triangle can be plotted in Tikz:

3. Here is Mr. Christopher Olah from Toronto explaining some aspects of Pascal's triangle on his blog:

4. Of course wikipedia has very interesting info on Pascal's Triangle too: