Coder Social home page Coder Social logo

latex-bingo's People

Contributors

bkanuka avatar hdevalence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

latex-bingo's Issues

Doesn't work well with unicode characters

I had to make some modification to the script to use Unicode characters. I've attached my modified shell script. I had to hard code the font because I had to use the albatross program to find a font installed on my computer to deal with it. Don't know how it could be made more generic. I also had to use xelatex not pdflatex in order to get it to work.

So while this isn't a fix for everyone, it was a workaround for me.

#!/usr/bin/bash

## text file which contains bingo squares
input_text=squares

## latex code for center square
center_square='\includegraphics[width=0.9\textwidth]{center.png}'
#center_square=FREE


node=( AA AB AC AD AE BA BB BC BD BE CA CB CD CE DA DB DC DD DE EA EB EC ED EE )

cat > bingo.tex << EOF
% !TeX TS-program = lualatex  
\documentclass{article}
% Added for Unicode (Korean) font
% ==========================
\usepackage[utf8]{inputenc}
\usepackage[a4paper,margin=2cm]{geometry}
% ==========================
\usepackage{xstring}
\usepackage[none]{hyphenat}
\usepackage{tikz}
\usetikzlibrary{calc}
\renewcommand{\familydefault}{\sfdefault}

\newcommand{\Size}{3cm}% Adjust size of square as desired

\def\NumOfColumns{5}%
\def\Sequence{1/A, 2/B, 3/C, 4/D, 5/E}% This needs to match \NumOfColumns 

\tikzset{Square/.style={
    inner sep=0pt,
    text width=\Size, 
    minimum size=\Size,
    draw=black,
    align=center
    }
}
EOF

i=0
OLDIFS=$IFS
IFS=$'\n'
for line in $(sort -R $input_text | head -n 24)
do
    echo "\newcommand{\Node${node[i]}}{$line}%" >> bingo.tex
    (( i++ ))
done
IFS=$OLDIFS

echo "\newcommand{\NodeCC}{$center_square}%" >> bingo.tex

cat >> bingo.tex << EOF
\pagestyle{empty}

% Used for Korean Fonts.
% ==========================
\usepackage{fontspec}
\setsansfont{Noto Serif CJK KR} 
% ==========================
\begin{document}
\centering
% Optional Title
\vspace*{\fill}
    \begin{center}
        \begin{tikzpicture}[draw=black, ultra thick, x=\Size,y=\Size]
            \node at (0.5,-0.8) {\Huge B};
            \node at (1.5,-0.8) {\Huge I};
            \node at (2.5,-0.8) {\Huge N};
            \node at (3.5,-0.8) {\Huge G};
            \node at (4.5,-0.8) {\Huge O};
            \foreach \col/\colLetter in \Sequence {%
                \foreach \row/\rowLetter in \Sequence{%
                    \pgfmathtruncatemacro{\value}{\col+\NumOfColumns*(\row-1)}
                    \def\NodeText{\expandafter\csname Node\rowLetter\colLetter\endcsname}
                    \node [Square] at (\$(\col,-\row)-(0.5,0.5)\$) {\LARGE \NodeText};
                }
            }
        \end{tikzpicture}
    \end{center}
\vspace*{\fill}
\end{document}
EOF

#pdflatex bingo.tex
xelatex bingo.tex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.