I am creating a script to produce some .tex
files with a lot of lines (a kind of automatic sample).
The script finishes with texstudio /home/$USER/foo.tex
where foo.tex
is the file created before.
My question is: is it possible to open the file with texstudio
with the cursor at line N, that is, I would like to run the script to open the file and start typing right now, exactly at the right line.
Thanks for a while. Below is the script.
file=/home/$USER/fastex-temp.tex
exec 3>&1 # save file descriptor to stdout
exec > "$file" # redirect output to file
printf '\\documentclass[11pt,a4paper]{amsart}\n'
printf '\\usepackage{amsfonts,amsthm,amsmath}\n'
printf '\\usepackage[latin1]{inputenc}\n'
printf '\\usepackage[T1]{fontenc}\n'
printf ' ' >&3 # output to normal stdout instead of file
printf '\\begin{document}\n'
printf ' ' >&3
printf '\\end{document}\n'
exec >&3 # restore stdout
exec 3>&- # close / discard temporary fd
texstudio "$file"
$EDITOR +42 foo.tex
to openfoo.tex
at line 42. I don't know if TeXstudio follows it.printf ' ' >&3
will produce an empty line? This is what I wish.printf ' '
prints a space. Your script would be more readable with a here document (search on this site for examples).# output to normal stdout instead of file
. So, this line will print an empty space on a single line of the file or not?