LaTeX-Utilities icon indicating copy to clipboard operation
LaTeX-Utilities copied to clipboard

Beamer frame preview

Open basilgass opened this issue 5 years ago • 17 comments

Feature Request

I would like to be able to preview one frame from a beamer presentation, similar to what's done with tikzpreview.

Is your feature request related to a problem? Please describe.

Nothing particular.

Describe the solution you'd like

I would like something similar to tikzpreview. The script should detect the \begin{frame}...\end{frame} tags. It would then isolate the current frame and display it in a new tab. As option, I think it would be great to have the choice to activate the "handout" option.

Describe alternatives you've considered

As alternative, I think a more general version of "preview" would be great. For example, when the cursor is in an environnement, he could activate the preview for this environnement. This would be usefull to create table, arrays and have the preview auto update after a a timeout.

Additional context

Nothing particular.

basilgass avatar Dec 09 '19 07:12 basilgass

I happen to have been thinking the same thing myself. I think a general "preview cursor selection" and setting for environments to preview would be a good idea.

Unfortunately, there are a few things currently in the pipeline, so for the moment this will have to be put asside. However if you wanted to see it sooner and help out a bit I'd welcome a PR!

tecosaur avatar Dec 09 '19 07:12 tecosaur

So far, I was able to modify the existing files to make it work with a beamer presentation instead of TikzPictures (but certainly have to do some optimization).

What I need to do now is creating and including new files in Latex-utilities. My first attempts weren't successfull... I need to understand a little bit more how the things works. In particular, my new codelense seems to not be detected...

I'll try to work on this in the coming days!

basilgass avatar Dec 14 '19 11:12 basilgass

Lovely! I'm afraid I'm a bit too busy to work on this right now, but if you're willing to get this to the state where you can make a PR that would be marvellous :tada:.

What I can do is try to answer questions, and offer tips :smiley:

Re: the code lense, I'd try to approach this by modifying providers/tikzcodelense.ts

https://github.com/tecosaur/LaTeX-Utilities/blob/2d5dba7fae1137e231a3fa8981eefb62d7c96157/src/providers/tikzcodelense.ts#L32-L33

For actually getting it to work well, I'd look at components/tikzpreview.ts, it shouldn't require too much work, you just need to generalise a few aspects of it.

https://github.com/tecosaur/LaTeX-Utilities/blob/2d5dba7fae1137e231a3fa8981eefb62d7c96157/src/components/tikzpreview.ts#L150-L151

https://github.com/tecosaur/LaTeX-Utilities/blob/2d5dba7fae1137e231a3fa8981eefb62d7c96157/src/components/tikzpreview.ts#L175

It would also probably be worth just chucking the whole preamble in, instead of having the tikz-specific stuff currently happening.

https://github.com/tecosaur/LaTeX-Utilities/blob/2d5dba7fae1137e231a3fa8981eefb62d7c96157/src/components/tikzpreview.ts#L286

The other big tweak that I'd consider beneficial is if it could be made to work on any selection, not just specific environments, but consider that a 'stretch' goal :wink:

Anyway, best of luck, and I hope this goes well!

tecosaur avatar Dec 14 '19 16:12 tecosaur

@basilgass how's it going?

tecosaur avatar Dec 21 '19 08:12 tecosaur

@tecosaur I'm working on it. Unfortunately, I had too much things to do last week. I'll try to finish this during the next days :)

basilgass avatar Dec 21 '19 11:12 basilgass

I'm just glad to hear you're still on it :)

tecosaur avatar Dec 21 '19 15:12 tecosaur

@basilgass managed to squeeze any more time in for this, or too busy around Christmas? :stuck_out_tongue_winking_eye:

tecosaur avatar Jan 04 '20 16:01 tecosaur

Hi! Christmas is taking a LOT of time :)

I have it working.,, But I'm encountering one or two problems:

  1. What compiler to use ? If the user is using LuaLaTeX or something else, the actual system won't work. I should add a preference so the user can choose a "recipe" for the preview.

  2. Wondering if it wouldn't be easier to set "presentation:0" to all frame execpt currently focused. This way, the user would only need to compile using their recipe. What do you think ?

  3. Another thing is adding a preferences to enable/disable the "handout" feature.

Another question concerning the Codelense technology - I wanted to make the beamer codelense in a different typescript file... But I didn't find the way to add two codelense for the same file type. Maybe I'm missing something...

basilgass avatar Jan 04 '20 17:01 basilgass

Hmm. You seem to be taking a different approach to that I would. Personally I'd less add a second similar tikzpreview.ts, and more generalise the file such that tikzpreview and beamerpreview are simply particular supported cases (and others can be arbitrarily added via user config).

With regards to your specific questions:

  1. I'd just use what the user currently has set as their default recipe, adding another setting seems like unnecessary duplication. The only other thing would be recognising %! TEX-MAGIC comments for building, but LaTeX-workshop does that already, we just need to pull that out of it.
  2. I haven't actually used beamer (yet) myself, so I'm not actually sure what you mean :sweat_smile:
  3. See (2)

Anyway, I look forward to seeing your work :smiley:, if you can though it would be really nice to have a solution which doesn't just support beamer and tikz, but any of a list of environments the user can provide, From memory, the current code should have 80% of what's needed for that.

tecosaur avatar Jan 04 '20 18:01 tecosaur

I'm stating it all over again! I will try to make every environnement work with this preview. As soon as I have something to show, I'll let you know 😃

basilgass avatar Jan 11 '20 22:01 basilgass

That sounds great! I'm just happy I'm not doing the work :stuck_out_tongue_closed_eyes:

tecosaur avatar Jan 12 '20 07:01 tecosaur

I didn't forgot. I have a working version... Except I'm encountering a problem (I had the same problem with the first version... This was one of the reason that made me restart the work).

First, how it works right now:

  1. I add in the preferences a string list of groups to identify and to display. An option allows to include or not stared items (equation and equation* for example).
  2. The codelense displays correclty, with an index for each groups.
  3. Clicking the "View in tab" is opening a new tab as expected (but it's not as fast as I would).

But... the problem comes with the update. When I modify something, the preview tab should update. Instead, it opens new tabs for each update... I don't know what's happening.

The problem comes from here: const refreshed = this.extension.workshop.viewer.refreshExistingViewer(tikzPicture.tempFile)

It returns false and, therefore, opens a new tab. I'm still investigating...

basilgass avatar Feb 04 '20 14:02 basilgass

It brings me great joy to hear that you are still working with this! Thank you very much for the update.

Unfortunately, I am as lost as you are from your description of the issue. I would love to help, however, for the next few weeks, time is going to be very tight for me.

All I can recommend is making the most of the built-in debugging tools, specifically the ability to pause at the troublesome point and use the console to test slightly different inputs.

Best of luck, and I look forward to seeing this feature in all its glory.

tecosaur avatar Feb 04 '20 15:02 tecosaur

@basilgass @tecosaur has something been discussed on this issue?

jsahil730 avatar Aug 19 '20 08:08 jsahil730

I haven't said anything since. I'm just here for questions or when there's something to be merged :)

tecosaur avatar Aug 19 '20 08:08 tecosaur

I tried multiple times to make this wokring correctly. And it was working... except of one thing - the peview was always opening a new tab, I didn't found a solution to refresh the preview tab instead of opening a new one. And since, lots of things happened for me... and I didn't had the time to investigate anymore.

Next thing was... as I developped this, the codelense appears... everywhere ! And it becomes hard to read the LaTeX code. So I'm not sure it's the correct way to do this. Maybe we could find an easier solution ?

basilgass avatar Aug 19 '20 20:08 basilgass

Hmm. Sounds like it's mostly working? If it is, perhaps consider creating a PR so any other interested people can chip in?

tecosaur avatar Aug 20 '20 10:08 tecosaur