I'll go direct to the point: I'm using Haskell to calculate the numbers that I want, these numbers always have some millions of digits (usually more than 15 million digits) and I'm throwing them into separately ".txt" files. How can I get the number from the file and use it with text formatting and etc? Basically it's use what is inside the file (one line only with the huge number, no extra lines)
Asked
Active
Viewed 379 times
2
2 Answers
3
num.txt a one line list of digits and
\documentclass{article}
\makeatletter
\def\fooinput#1{\begingroup
\everyeof{\stopfooinput\endgroup}%
\expandafter\xfooinput\@@input#1\relax}
\def\xfooinput#1{#1\penalty\z@\xfooinput}
\def\stopfooinput#1#2#3{}
\makeatother
\begin{document}
\fooinput{num.txt}
\end{document}
David Carlisle
- 757,742
-
Hoping that the big number doesn't overflow memory due to the gigantic paragraph being typeset. – egreg Jun 23 '16 at 14:30
-
By the way, the buffer size should be increased. A 1MiB file causes
TeX capacity exceeded, sorry [main memory size=5000000]– egreg Jun 23 '16 at 14:39 -
@egreg yes I suppose I could throw in a par every n characters.... – David Carlisle Jun 23 '16 at 14:39
-
The 1MiB file compiles with
buf_size=20000000 extra_mem_top=10000000 pdflatex bignum, creating 331 completely useless pages.;-)– egreg Jun 23 '16 at 14:41 -
-
-
Well i'm just a crazy guy who loves those big numbers that have a reason for being big, like large prime numbers or the nth term of a sequence and things like that, me and more 2 friends of mine we enjoy it so much that we're gonna print them, and i need to put them into a small monospace font into a pdf and send to print, LaTeX is the best option that i have to that – Iago Sousa Jun 23 '16 at 14:55
-
@IagoSousa There are several Unix tools for massaging big files and making them into well manageable chunks. – egreg Jun 23 '16 at 14:57
-
@IagoSousa I could adjust it to print each line as a paragraph then memory consumption would be much less, – David Carlisle Jun 23 '16 at 14:57
-
2
-
i'm uploading one of the files to my drive, cool thing about it is that this 22million number was generated in less than 5 seconds but needed more than a minute to actually open the txt file – Iago Sousa Jun 23 '16 at 15:01
-
For what egreg meant: see http://unix.stackexchange.com/questions/60219/is-there-a-command-line-tool-to-insert-line-breaks-into-a-long-string – Willie Wong Jun 23 '16 at 15:03
-
3
OFF TOPIC ANSWER
I really doubt LaTeX is the best tool. For example, off the top of my mind:
install
a2ps(in Debian/Ubuntu you have a package with the same name);run
a2ps -o lalla.ps -4 bignumber.txtit will say
[bignumber.txt (plain): 22 pages on 6 sheets] [Total: 22 pages on 6 sheets] saved into the file `lalla.ps' [1375 lines wrapped]enjoy your crime against trees ;-)
This is four logical pages per sheet, but you can play with the options to have more compact or bigger fonts or whatever. man a2ps is your friend.
After that you can use ps2pdf kind of filter to convert it to PDF.
Rmano
- 40,848
- 3
- 64
- 125
-
1i got it [primo.txt (plain): 4296 pages on 1074 sheets] [Total: 4296 pages on 1074 sheets] saved into the file `lalla.ps' [279232 lines wrapped] – Iago Sousa Jun 23 '16 at 18:55


\input{number.txt}. – Runar Jun 23 '16 at 14:04input{}directly, as made very clear by egreg and David Carlisle. I'll leave this one to them and the other big boys around here. – Runar Jun 23 '16 at 14:51