Menu

#2351 Preview using pdflatex error when using \input with a relative path

open
nobody
None
1
2018-02-12
2018-01-27
Anonymous
No

Previews don't compile when I'm using "\input" with a relative path. Once I take out my "\input", the previews work as normal.

Discussion

  • Rushi

    Rushi - 2018-02-11

    I have observed this as well. A MWE is added here.
    MWE/test/test.tex - main file
    MWE/macros.tex - definition of some macros
    Observations:

    1. Document compiles correctly.
    2. Idefix -> preview selection/parentheses works.
    3. Tooltip preview does not work, log shows trouble finding macros.tex.
    4. Tooltip preview starts working again if either of the following are true:
      a. \input is used with absolute path instead of relative path.
      b. \input is placed in the document instead of the preamble. In this case, the previews do not seem to recognize the macros in the macros.tex file

    Placing \input in the document instead of preamble is fine for macros but, not if the file being input contains any preamble-only commands.

     

    Last edit: Rushi 2018-02-11
  • Jan  Sundermeyer

    Jan Sundermeyer - 2018-02-11

    the issue that the compilation of a "preview"-tex-file is taking place in the temp directory. Hence preamble which have relative paths in it, don't work.
    I don't think that I want to find a work-around for this.

     
  • Rushi

    Rushi - 2018-02-11

    Hi Jan,

    From what I understand, the workaround is already there in the implementation of Idefx -> Preview Selection/Paranthesis. When select the equation in the example I attached to my previous comment and press Idefx -> Preview Selection/Paranthesis, TexStudio does two things:

    1. Creates a temp file (lets call this temp1.tex) with the contents
      \documentclass{article} \usepackage{amsmath} \input{C:/**absolute_path**/MWE/macros.tex} \usepackage[active,tightpage]{preview} \usepackage{varwidth} \AtBeginDocument{\begin{preview}\begin{varwidth}{\linewidth}} \AtEndDocument{\end{varwidth}\end{preview}} \pagestyle{empty}
      Here TexStudio is able to parse my relative path and convert it to an absolute path.

    2 Creates another temp file (let's call this temp2.tex) with the contents
    %&temp1 \begin{document} \begin{equation*} f\left(t\right)=g\left(t\right), \forall t\in\ropen{0,\infty}. \end{equation*} \end{document}

    temp2.tex then compiles correctly.

    Whem I hover over \begin, TexStudio again creates two temp files. This time though, the path is not converted to absolute path in temp1.tex. Also, a precompiled temp1.fmt is no longer used in temp2.tex like before (this is probably because pdflatex fails to create the fmt file because the relative path is not correct). That is, I get

    temp1.tex:

    \documentclass{article} \usepackage{amsmath} \input{../macros.tex} \usepackage[active,tightpage]{preview} \usepackage{varwidth} \AtBeginDocument{\begin{preview}\begin{varwidth}{\linewidth}} \AtEndDocument{\end{varwidth}\end{preview}} \pagestyle{empty}

    temp2.tex

    \documentclass{article} \usepackage{amsmath} \input{../macros.tex} \usepackage[active,tightpage]{preview} \usepackage{varwidth} \AtBeginDocument{\begin{preview}\begin{varwidth}{\linewidth}} \AtEndDocument{\end{varwidth}\end{preview}} \pagestyle{empty} \begin{document} \begin{equation*} f\left(t\right)=g\left(t\right), \forall t\in\ropen{0,\infty}. \end{equation*} \end{document}

    Of course, this time, temp2.tex does not compile correctly.

    Is there no way to replicate the existing functionality of Idefx -> Preview Selection/Paranthesis (which parses and converts relative paths to absolute paths before exporting temp1.tex) when compiling the tooltip previews?

     

    Last edit: Rushi 2018-02-11
  • Jan  Sundermeyer

    Jan Sundermeyer - 2018-02-12

    I will look into it.

     

Log in to post a comment.