Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work well with unicode characters #2

Open
rdearman opened this issue Aug 20, 2022 · 0 comments
Open

Doesn't work well with unicode characters #2

rdearman opened this issue Aug 20, 2022 · 0 comments

Comments

@rdearman
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant