GeneralIncluding a value from a file

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Badders
Posts: 3
Joined: Tue Feb 24, 2015 6:14 pm

Including a value from a file

Post by Badders »

So i have a script that does some simulations then saves out a number to a file (as well as some figures and other things), and i want to be able to include the number in the text of my latex document without changing it by hand every time the script is run.

At the moment the best solution i have is to use the verbatim input module.

However, this always puts the file on a newline, whereas ideally i would like to just to include the text value at the current position, without any formatting etc.

So at the moment i do:

Value of result: \VerbatimInput{file.txt} more text here

Which gives:

Value of result:
182.45
more text here

Whereas i would ideally like:
Value of result: 182.45 more text here

I have searched around for an answer to this and all i can seem to find is solutions for when the result is calculated in latex, rather than just included as an external text file.

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Including a value from a file

Post by Johannes_B »

Hi and welcome,

you can change the script, right? Easiest solution seems to be to write your special value to a file mySpecialValue.tex which just has the value.

In you text you can get the special value using \input{mySpecialValue}.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Badders
Posts: 3
Joined: Tue Feb 24, 2015 6:14 pm

Re: Including a value from a file

Post by Badders »

I just tried that, it gives an even worse result, it page breaks before the included file :(

Any ideas what else to try? im at a loss?

Thanks
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Including a value from a file

Post by Johannes_B »

That simply cannot (shouldn't) happen. Can you try to make a minimal working example, that shows the behaviour?
The input-solution is the simplest and least error prone way.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Badders
Posts: 3
Joined: Tue Feb 24, 2015 6:14 pm

Re: Including a value from a file

Post by Badders »

Yeah my mistake, i did \include not \input, im very tired :)

Your solution worked perfectly, thanks very much!
Post Reply