2

How can I read out \char"1F0A1,...,\char"1F0DF
that means \char127137, ..., \char127199
with a foreach-loop?

I got Dimensions too large if I use the second version; and TikZ does not like hexadecimal numbers at the first version.

Does TikZ know a solution here or is that only possible with other things?

Hint: By using the font Segoe UI Symbol or DejaVu Sans this should give the unicode play card symbols:
enter image description here

Test-MWE with incorrect numbers:

% arara: lualatex
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage{fontspec}
\newfontfamily\myfont{DejaVu Sans}

\begin{document}
\section{Test:}

\foreach[evaluate={  \LineBreak=(  int( mod(\n-1,13) ) },
evaluate={  \Seperator=(  \LineBreak==12 ? "." : ",~")  }
] \n in {14,...,78}{%% <--- here are not the correct numbers... 
\myfont\char"\n      \Seperator \ifnum\LineBreak=12 \\ \fi 
}%%
\end{document}

enter image description here

4
  • 4
    \foreach \n in {0,...,64}{\myfont\char\inteval{\n+127137}} Jun 8 at 8:41
  • works......... :()
    – cis
    Jun 8 at 8:49
  • @UlrikeFischer Why not making an answer from that?
    – cis
    Jun 8 at 10:11
  • @egreg says the same at the begin of his answer only with \numexpr instead of \inteval, which is faster but not so modern. Jun 8 at 10:21

1 Answer 1

5

You may probably get away with a \foreach loop from 37 to 99, using arithmetic for printing the right glyph

\char\numexpr127100+\n\relax

Here's a different loop; note that the playing cards block has sixteen slots for each suit.

\documentclass[a4paper]{article}
\usepackage{fontspec}

\newfontfamily\cardfont{DejaVu Sans}

\ExplSyntaxOn
\NewDocumentCommand{\intstep}{m O{1} m +m}
 {% #1 = start, #2 = step, #3 = end, #4 = action
  \int_step_inline:nnnn { #1 } { #2 } { #3 } { #4 }
 }
\NewDocumentCommand{\actionmodulo}{m m +m +m}
 {% #1 = integer to test, #2 = modulo, #3 = normal action, #4 = action at multiples of #1
  \int_compare:nTF { \int_mod:nn { #1 } { #2 } == 0 } { #4 } { #3 }
 }
\ExplSyntaxOff

\newcounter{step}

\begin{document}

\intstep{"1F0A1}{"1F0DF}{%
  {\cardfont\symbol{#1}}%
  \stepcounter{step}%
  \actionmodulo{\value{step}}{16}{, }{.\par}%
}

\end{document}

enter image description here

You may modify the loop to discard the unwanted slots.

3
  • Eh...? Sixteen what? A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 und K (Knight) makes 14? What is still missing?
    – cis
    Jun 8 at 8:58
  • @cis Ask the Unicode people: there are J and C (probably for taking into account different national conventions) and one or two reserved slots after each block. At the end of the diamonds block there's the red joker and one reserved slots; similarly at the end of the clubs block.
    – egreg
    Jun 8 at 9:22
  • Eh, I saw, it is C = Knight (e.g. C♥ 'Knight Heart'). So I think the addition is Knight, "Star Card" (?) -as I see in your picture- and Joker for each suit (?).
    – cis
    Jun 8 at 10:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .