Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long Filenames in "includegraphics" #1

Closed
gro1729 opened this issue Aug 19, 2015 · 21 comments
Closed

Long Filenames in "includegraphics" #1

gro1729 opened this issue Aug 19, 2015 · 21 comments
Assignees

Comments

@gro1729
Copy link

gro1729 commented Aug 19, 2015

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
Copy link
Owner

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
Copy link
Owner

Hello,

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

@gro1729
Copy link
Author

gro1729 commented Aug 24, 2015

                                                                                  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
Copy link
Author

gro1729 commented Aug 24, 2015

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
Copy link
Owner

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 fchauvel reopened this Aug 24, 2015
fchauvel added a commit that referenced this issue Aug 25, 2015
@fchauvel fchauvel self-assigned this Aug 25, 2015
@fchauvel
Copy link
Owner

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

@gro1729
Copy link
Author

gro1729 commented Aug 26, 2015

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
#1 (comment).

@gro1729
Copy link
Author

gro1729 commented Aug 26, 2015

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
Copy link
Owner

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

@gro1729
Copy link
Author

gro1729 commented Aug 29, 2015

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
Copy link
Author

gro1729 commented Aug 29, 2015

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

Is there a "old fashioned"-replacement?

@fchauvel
Copy link
Owner

I create a separate issue about the Compatibility with Python 3.2

@gro1729
Copy link
Author

gro1729 commented Aug 31, 2015

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

  • in 'EinfuehrungLaTeX.tex' line 69: '\input{defineStartingAndPresentationPlace}'
  • in 'EinfuehrungLaTeX.tex' line 72: '\input{pathSettings}'
  • in 'EinfuehrungLaTeX.tex' line 75: '\input{presentationPlace}'
    Traceback (most recent call last):
    File "/home/gro/.pythonbrew/pythons/Python-3.2/lib/python3.2/runpy.py", line 160, in _run_module_as_main
    "main", fname, loader, pkg_name)
    File "/home/gro/.pythonbrew/pythons/Python-3.2/lib/python3.2/runpy.py", line 73, in _run_code
    exec(code, run_globals)
    File "/home/gro/tefeld/Templates/LaTeX/Presentations/biz/flap/main.py", line 21, in
    main(sys.argv)
    File "flap/ui.py", line 105, in main
    Controller(OSFileSystem()).run(arguments)
    File "flap/ui.py", line 83, in run
    self.flap.flatten(rootFile, output)
    File "flap/engine.py", line 341, in flatten
    self.merge_latex_source()
    File "flap/engine.py", line 356, in merge_latex_source
    merge = ''.join([ f.text() for f in fragments ])
    File "flap/engine.py", line 356, in
    merge = ''.join([ f.text() for f in fragments ])
    File "flap/engine.py", line 178, in fragments
    for each_fragment in self._delegate.fragments():
    File "flap/engine.py", line 178, in fragments
    for each_fragment in self._delegate.fragments():
    File "flap/engine.py", line 179, in fragments
    for f in self.process_fragment(each_fragment): yield f
    File "flap/engine.py", line 185, in process_fragment
    for f in self.replacements_for(fragment, eachMatch): yield f
    File "flap/engine.py", line 272, in replacements_for
    graphic = self.select_image_file(fragment, match, path)
    File "flap/engine.py", line 280, in select_image_file
    raise ValueError("Unable to find any file for graphic '%s' in '%s'" % (match.group(1), fragment.file().container().path()))
    ValueError: Unable to find any file for graphic '
    startingPlace' in '/'

but modifying the inclusion to:

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

works fine.

@fchauvel
Copy link
Owner

fchauvel commented Sep 1, 2015

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

flap/tests/unit/engine.py

Lines 249 to 261 in 3285956

def test_path_to_local_images_are_not_adjusted(self):
self.create_main_file(r"""
\includegraphics[interpolate,width=11.445cm]{%
startingPlace}
""")
self.create_image("startingPlace.pdf")
self.run_flap()
self.verify_merged(r"""
\includegraphics[interpolate,width=11.445cm]{startingPlace}
""")
self.verify_image("startingPlace.pdf")
. Did you face this issue with v0.2.4?

@gro1729
Copy link
Author

gro1729 commented Sep 1, 2015

                                                                                  ‎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
Copy link
Author

gro1729 commented Sep 1, 2015

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

  • in 'EinfuehrungLaTeX.tex' line 69: '\input{defineStartingAndPresentationPlace}'
  • in 'EinfuehrungLaTeX.tex' line 72: '\input{pathSettings}'
  • in 'EinfuehrungLaTeX.tex' line 75: '\input{presentationPlace}'
    Traceback (most recent call last):
    File "/home/gro/.pythonbrew/pythons/Python-3.2/lib/python3.2/runpy.py", line 160, in _run_module_as_main
    "main", fname, loader, pkg_name)
    File "/home/gro/.pythonbrew/pythons/Python-3.2/lib/python3.2/runpy.py", line 73, in _run_code
    exec(code, run_globals)
    File "/home/gro/tefeld/Templates/LaTeX/Presentations/biz/flap/main.py", line 21, in
    main(sys.argv)
    File "flap/ui.py", line 105, in main
    Controller(OSFileSystem()).run(arguments)
    File "flap/ui.py", line 83, in run
    self.flap.flatten(rootFile, output)
    File "flap/engine.py", line 355, in flatten
    self.merge_latex_source()
    File "flap/engine.py", line 370, in merge_latex_source
    merge = ''.join([ f.text() for f in fragments ])
    File "flap/engine.py", line 370, in
    merge = ''.join([ f.text() for f in fragments ])
    File "flap/engine.py", line 178, in fragments
    for each_fragment in self._delegate.fragments():
    File "flap/engine.py", line 178, in fragments
    for each_fragment in self._delegate.fragments():
    File "flap/engine.py", line 179, in fragments
    for f in self.process_fragment(each_fragment): yield f
    File "flap/engine.py", line 185, in process_fragment
    for f in self.replacements_for(fragment, eachMatch): yield f
    File "flap/engine.py", line 272, in replacements_for
    graphic = self.select_image_file(fragment, match, path)
    File "flap/engine.py", line 280, in select_image_file
    raise ValueError("Unable to find any file for graphic '%s' in '%s'" % (match.group(1), fragment.file().container().path()))
    ValueError: Unable to find any file for graphic '
    startingPlace' in '/'

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
Copy link
Author

gro1729 commented Sep 1, 2015

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
Copy link
Owner

fchauvel commented Sep 2, 2015

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 #1 (comment)). Let me know what you get, if you give it a try.

@gro1729
Copy link
Author

gro1729 commented Sep 3, 2015

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
Copy link
Author

gro1729 commented Sep 3, 2015

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
Copy link
Owner

fchauvel commented Sep 3, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants