fchauvel / flap

Flattening LaTeX projects
https://fchauvel.github.io/flap
GNU General Public License v3.0
17 stars 2 forks source link

Long Filenames in "includegraphics" #1

Closed gro1729 closed 8 years ago

gro1729 commented 9 years ago

Hello, this is a great tool!

Unfortunately, I am not an expert in regular expressions. I have problems with the includegraphics-command. Usually, I prefer to write options in the first line, followed by a comment sign. In the second line follows the name of the image

\includegraphics[interpolate,width=\columnwidth,height=1.\textheight,keepaspectratio]{% figures/DirectoryOne/ImageTwo}

Additionally, I use "includesvg". The Macro converts SVG-files on the fly into pdf-files. It would be great, if this "include"-state could also be recognized.

Thanks in advance and regards from Andreas

fchauvel commented 9 years ago

Hello, Thanks for giving FLaP a try. As for the commands spanning over several lines, the problem must come from the way FLaP strips out comments. I will take a look at that tonight and let you know as soon as I got a fix. Regarding the \includesvg command, I will give a try and let you know as well.

fchauvel commented 9 years ago

Hello,

I gave a trying a the features we discussed. Please checkout version 0.2.0 (Commit 42b893e14c66d4574d48c6617929faafcb21cae9) and let me know if face any problem.

gro1729 commented 9 years ago
                                                                                  Great, Thanks a lot.                                                                                                                                                                                                                                                                                                                                        Gruß von Andreas Grotefeld                                                                                                                                                                                                                 Von: Franck ChauvelGesendet: Montag, 24. August 2015 09:06An: fchauvel/flapAntwort an: fchauvel/flapCc: gro1729Betreff: Re: [flap] Long Filenames in "includegraphics" (#1)Closed #1.

—Reply to this email directly or view it on GitHub.

gro1729 commented 9 years ago

Dear Franck Chauvel,

your software is great and I would not have been be able to implement it. I tried your new files on Unix with Python 3.2 and had some problems with "yield from". I did some Replacements in "core.py", that worked fine for me.

yield from [ Fragment(self._file) ]

    for v in [ Fragment(self._file) ]: yield v

yield from self.processFragment(eachFragment)

        for v in self.processFragment(eachFragment): yield v

yield from self.replacementsFor(fragment, eachMatch)

        for v in self.replacementsFor(fragment, eachMatch): yield v

But the "\input"- directive still results in some problems:

 % Works with TeXLive, TeXWorks and TeXStudio on Linux but not on

Windows \input{slides/% EineKurzeEinfuehrungInLaTeX/% Einfuehrung/% WasSindTeXUndLaTeX}

  % Works with TeXLive, TeXWorks and TeXStudio on Linux and on Windows
  % and would be great

\newcommand{\Einfuehrung}{slides/EineKurzeEinfuehrungInLaTeX/Einfuehrung} \input{\Einfuehrung/WasSindTeXUndLaTeX}

  % Works with TeXLive, TeXWorks and TeXStudio on Linux and on

Windows but results in very long lines. % This is my current workaround I am using

\input{slides/EineKurzeEinfuehrungInLaTeX/Einfuehrung/WasSindTeXUndLaTeX}

I have some problems in understanding your inclusion-algorithmn. I am using always the same "includesvg" statement and the "includegraphics" statement as well. In the directory with the merged files I find the following list of files.

PocketmodFaltanleitung00.svg
PocketmodFaltanleitung01.svg
PocketmodFaltanleitung02.svg
PocketmodFaltanleitung03.pdf
PocketmodFaltanleitung04.pdf
PocketmodFaltanleitung05.pdf
PocketmodFaltanleitung06.pdf
PocketmodFaltanleitung07.svg
PocketmodFaltanleitung08.pdf
PowerdotLayoutBakomaTeX01.jpg
PowerdotLayoutBakomaTeX02.jpg
PowerdotLayoutBakomaTeX03.xcf

Do you have any ideas?

Best regards from Andreas

Andreas F.W. Grotefeld Rauschbergstraße 3 82194 Gröbenzell

(+49) 8142 / 597506 (+49) 170 / 6186546 grotefeld.de

Please avoid sending me Word or PowerPoint attachments: http://www.gnu.org/philosophy/no-word-attachments.html

fchauvel commented 9 years ago

Hello,

Thanks a lot for the feedback. I will replace these occurences of yield from.

Regarding the \input{} directive, I guess the current version only supports comments used before or after the file , as in the following example. This being said, I should be possible to fix this, in the way path are processed.

\include{%
     my/dir/file%
     }

As for the inclusion algorithm, I think it takes the first file, which matches the name found in the LaTeX source. Here, I am not so clear what that would return, as it depends on the order files are returned by the os Python module.

I will let you know as soon as I get something working.

fchauvel commented 9 years ago

I gave a try at fixing the two problems you mentioned. Please check out v0.2.1. Let me know any further issue.

gro1729 commented 8 years ago

Hello and good morning,

yesterday and today in the morning before going to work, I didn't have enough time to fix the problem.

I have a simple slide:

\begin{frame} \frametitle{\TheStartingPlace} \begin{center} \includegraphics[interpolate,width=11.445cm]{% startingPlace} \end{center} \end{frame}

with an image "startingPlace.jpg" (I also tried "startingPlace.png")

I get the following stacktrace:

File "flap/core.py", line 328, in flatten self.mergeLaTeXSource() File "flap/core.py", line 343, in mergeLaTeXSource merge = ''.join([ f.text() for f in fragments ]) File "flap/core.py", line 343, in merge = ''.join([ f.text() for f in fragments ]) File "flap/core.py", line 176, in fragments for eachFragment in self._delegate.fragments(): File "flap/core.py", line 178, in fragments for f in self.processFragment(eachFragment): yield f File "flap/core.py", line 185, in processFragment for f in self.replacementsFor(fragment, eachMatch): yield f File "flap/core.py", line 271, in replacementsFor graphic = self.selectGraphicFile(fragment, match, path) File "flap/core.py", line 279, in selectGraphicFile raise ValueError("Unable to find file for graphic '%s' in '%s'" % (match.group(1), fragment.file().container().path())) ValueError: Unable to find file for graphic 'startingPlace' in '/'

What do I have to change?

Thanks in advance and regards

Am 25.08.2015 13:44, schrieb Franck Chauvel:

I gave a try at fixing the two problems you mentioned. Please check out v0.2.1. Let me know any further issue.

— Reply to this email directly or view it on GitHub https://github.com/fchauvel/flap/issues/1#issuecomment-134561665.

gro1729 commented 8 years ago

Uups, there is another "include"-Environment, I use:

        \begin{overpic}[scale=0.25,unit=1mm,grid,tics=10]{%
           figures/TeXMakerUndStudioUndCo/DieHardcoreVariante/AcrobatReader}
        \end{overpic}
fchauvel commented 8 years ago

I fixed the issue you had in version 0.2.2 and I added support for the òverpic`environment. Feedback is welcome.

gro1729 commented 8 years ago

Again! It would be a nice tool, I really would need. But it does not any longer work for Python 3.2. It's a pitty.

gro1729 commented 8 years ago

for f in self.replacements_for(fragment, eachMatch): yield f seems to be the problem.

Is there a "old fashioned"-replacement?

fchauvel commented 8 years ago

I create a separate issue about the Compatibility with Python 3.2

gro1729 commented 8 years ago

I still have problems with slides in the "root"-folder of my presentation-structure, if the slides are referencing images in this "root"-folder:

This slides

\begin{frame} \frametitle{\TheStartingPlace} \begin{center} \includegraphics[interpolate,width=11.445cm]{% startingPlace} \end{center} \end{frame}

in a stack-trace

but modifying the inclusion to:

        \includegraphics[interpolate,width=11.445cm]{%
           ./startingPlace}

works fine.

fchauvel commented 8 years ago

I haven't not been able to reproduce this issue. There is actually a test covering it, which passes both on my machine (Windows) and on the continuous integration server (Linux). The test case is available at see https://github.com/fchauvel/flap/blob/3285956cce4dbaffb3381ed9974cb9b31fba8b15/tests/unit/engine.py#L249-L261. Did you face this issue with v0.2.4?

gro1729 commented 8 years ago
                                                                                  ‎I will check it today in the afternoon                                                                                                                                                                                                                                                                                                                                        Gruß von Andreas Grotefeld                                                                                                                                                                                                                 Von: Franck ChauvelGesendet: Dienstag, 1. September 2015 08:40An: fchauvel/flapAntwort an: fchauvel/flapCc: gro1729Betreff: Re: [flap] Long Filenames in "includegraphics" (#1)I haven't not been able to reproduce this issue. There is actually a test covering it, which passes both on my machine (Windows) and on the continuous integration server (Linux). The test case is available at see https://github.com/fchauvel/flap/blob/3285956cce4dbaffb3381ed9974cb9b31fba8b15/tests/unit/engine.py#L249-L261. Did you face this issue with v0.2.4?

—Reply to this email directly or view it on GitHub.

gro1729 commented 8 years ago

I just tested with the new version and on Linux I get the same problem:

Using Python-3.2
FLaP v0.2.4 -- Flat LaTeX Projects

changing from "startingPlace"

  \begin{frame}
     \frametitle{\TheStartingPlace}
        \begin{center}
           \includegraphics[interpolate,width=11.445cm]{%
              startingPlace}
        \end{center}
  \end{frame}

to "./startingPlace" is a blemish.

  \begin{frame}
     \frametitle{\TheStartingPlace}
        \begin{center}
           \includegraphics[interpolate,width=11.445cm]{%
              ./startingPlace}
        \end{center}
  \end{frame}

The same holds for your example

Main file Included File (foo.tex) Output File <--->\input{foo} \begin{frame} some content \end{frame} <--->\begin{frame} some content \end{frame}

Important is the fact, that fragile slide are not more indented than in the original file.

gro1729 commented 8 years ago

Find enclosed the modifications by hand in my test presentation with 144 slides: (That's great, I think!)

316c316 < \verb|| \verb|{| \verb|}| \verb|

  >                   \verb|| \verb|{| \verb|}| \verb|%| \verb|~| \verb|&|

322c322 < \cs{textbackslash} \verb|{| \verb|}| \verb|\

  >                \cs{textbackslash} \verb|{| \verb|}| \verb|\%| \cs{textasciitilde}

360c360 < \textcolor<3>{blue116}{\

  >    \textcolor<3>{blue116}{\% This is a comment}
fchauvel commented 8 years ago

I just released a fix for a bug occurring when one tries to run FLaP from the directory where the main latex source file is located. Something like:

$> python -m flap main.tex merged

I hope it will fix as well the issue you had mentioned (see https://github.com/fchauvel/flap/issues/1#issuecomment-136327418). Let me know what you get, if you give it a try.

gro1729 commented 8 years ago

Yes, you are right, this slides works now:

  \begin{frame}
     \frametitle{\ThePresentationPlace}
        \begin{center}
           \includegraphics[interpolate,width=11.445cm]{%
              presentationPlace}
        \end{center}
  \end{frame}
gro1729 commented 8 years ago

But now, I have another problem. FLaP also tries to "export" my "beamertheme"-files. (These local files are symbolic links, that results in the message: "shutil.Error: ./beamerinnerthemeGrotefeld.sty and flattened/beamerinnerthemeGrotefeld.sty are the same file")

(Local) "beamertheme"-files expect a complex predefined file structure.

fchauvel commented 8 years ago

Ok, so I will close this issue, and open a new one specific for the "beamerthemes" files.