add tag
samcarter
I'd like to have a seed for random numbers, which depends on the current `\jobname`.

- the `\jobname` will consist only of lowercase alphabetic letters. No spaces, hyphens, numbers etc.
- the name will be < 20 characters long
- the jobname will be different from the filename and I would like the seed to be reproducible if I change the contents of the file.
- the seed does not have to be unique, it just needs to be reproducible and give a different seed in most cases. I would not mind if something `abc` and `cba` would give the same seed.
- should work with pdflatex and lualatex

Some skeleton code as a starting point:

```
\documentclass{standalone}

\ExplSyntaxOn
\sys_gset_rand_seed:n{42}
\ExplSyntaxOff
\edef\hue{\fpeval{rand()}}

\begin{document}
\hue
\end{document}
```
Top Answer
samcarter
My current approach is to covert each character to a number from 1 to 26 and then sum them up. Seems to work well enough for my use case.


```
\documentclass{article}

\ExplSyntaxOn
\int_new:N \int_mysum
\seq_clear:N \l_tmpa_seq

\text_map_inline:nn { \c_sys_jobname_str } { \seq_put_right:Nn \l_tmpa_seq { #1 } }
\seq_map_inline:Nn \l_tmpa_seq { \int_add:Nn \int_mysum { \int_from_alph:n { #1 } } } 
\sys_gset_rand_seed:n{ \int_mysum }
\ExplSyntaxOff

\edef\hue{\fpeval{rand()}}

\begin{document}

\hue

\end{document}
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.