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

Syntax for columns in presentations. #1710

Closed
AvverbioPronome opened this issue Oct 22, 2014 · 29 comments
Closed

Syntax for columns in presentations. #1710

AvverbioPronome opened this issue Oct 22, 2014 · 29 comments

Comments

@AvverbioPronome
Copy link

I believe it is necessary, even the beamer manual tells users to use columns in frames (§5.1.3).

Alternatives I have in mind are:

  • syntax for divs in Syntax for divs #168, with {.column width=xx%};
  • using the three-dotted syntax used in stmd for side by side examples.
@jgm
Copy link
Owner

jgm commented Oct 22, 2014

Pandoc is multiformat. I don't want to add syntax that is special to beamer.

If you want columns in your frames, you can:

  • Use raw latex (will only work in beamer)
  • Use divs as you suggest, and write a pandoc filter to convert to the needed
    column environments in beamer output (not too hard)
  • Use a table

+++ Giuseppe C [Oct 22 14 05:41 ]:

I believe it is necessary, even the beamer manual tells users to use columns in frames (§5.1.3).

Alternatives I have in mind are:

  • syntax for divs in Syntax for divs #168, with {.column width=xx%};
  • using the three-dotted syntax used in stmd for side by side examples.

Reply to this email directly or view it on GitHub:
#1710

@AvverbioPronome
Copy link
Author

It shouldn't be beamer-specific, but I guess presentation-specific is just as bad. (on the other hand, a presentation is very different from a document)

I thought columns could become subfloats in documents, and I wasn't very convinced.

@jgm
Copy link
Owner

jgm commented Oct 22, 2014

Well, I suppose we could hard-code a certain behavior for
<div class="column">, and add custom CSS to handle this
in HTML slide formats. This might be worth looking into.

@N4M3Z
Copy link

N4M3Z commented Oct 26, 2015

What is the progress on this? Something along the lines of {.column width=xx%} seems like the way to go. Can we help with implementing it?

@jgm
Copy link
Owner

jgm commented Oct 27, 2015

I like the div solution on the input side. What I'd need to know is what the output should look like in all of the slide show formats we support, or as many of them as support it -- but, at least, beamer and revealjs.

@jgm
Copy link
Owner

jgm commented Oct 27, 2015

I assume that in revealjs and other HTML formats we can use CSS to position things --- either floats or, probably more reliably,

<div style="display: inline-block; width: 50%; vertical-align: top;">
</div>

but I haven't actually tested this. In fact, it might be sensible to support this in all HTML output (whether slide or not).

@N4M3Z
Copy link

N4M3Z commented Oct 27, 2015

For Beamer, two column output should look like this:

\begin{columns}
  \begin{column}{0.48\textwidth}
    Left column
  \end{column}
  \begin{column}{0.48\textwidth}
   Right column
  \end{column}
\end{columns}

Which can be easily extended to multiple columns. I have been adding this to my markdown and it works fine.

There is a very nice summary of various options implemented by others: http://stackoverflow.com/questions/20847371/two-column-layouts-in-rstudio-presentations-slidify-pandoc

I like the R studio solution using the *** separator. But {.column width} is also nice.

@jgm
Copy link
Owner

jgm commented Oct 27, 2015

So, for beamer, if we have <div class="column" width="N%">, do we always want (N-1)\textwidth in beamer?

@N4M3Z
Copy link

N4M3Z commented Oct 27, 2015

Hmm, I think not. If I am not mistaken, the width percentages need not add to 1, LaTeX will simply not use the remaining space. Hence, we should be fine with specifying <div class="column" width="N%"> as N\textwidth. Let me know if you want me to do some testing.

@jgm
Copy link
Owner

jgm commented Oct 27, 2015

Another syntax possibility. Currently, if you use a header with level (slidelevel + 1), you'll get a block environment.

\begin{block}{Header}

contents

\end{block}

We could set things up so that, if the main header for a slide has the class "columns", then subsidiary headers create columns instead of blocks:

# My slide {.columns}

## First column

contents

## Second column

contents

Widths could be computed automatically (unless there is a really compelling reason for being able to specify them manually.) An empty header could be used if you don't want a subhead at the top of the column. This approach would be more naturally syntax-wise, but a bit less flexible.

@N4M3Z
Copy link

N4M3Z commented Oct 27, 2015

I consider the ability to specify width essential. This is particularly useful for side-by-side figures of different proportions.

Concerning the syntax, personally I am not sure I like it since I might want to use both blocks and columns. I still have a problem once I start using blocks, there is no way to tell pandoc to end the block and continue writing text outside the block and I am afraid the same thing would happen here.

However, I agree that it feels more natural w.r.t. markdown.

@jgm
Copy link
Owner

jgm commented Oct 27, 2015

Looks like currently the "block syntax" breaks entirely if you put it inside a div.
So we may need more serious changes to the LaTeX writer to make this all work smoothly.

@N4M3Z
Copy link

N4M3Z commented Oct 27, 2015

I suggest to take the simplest approach to bring the column functionality at least partially to pandoc and taking care of blocks inside columns later. It is a very unlikely use-case I would say.

@barronh
Copy link

barronh commented May 5, 2016

I can get basic usage with the standard beamer columns. I get a reasonable output with very little effort and only a minor modification of the default template.

I added one use statement and two new commands to my beamer template.

\newcommand{\begincols}[1]{\begin{columns}{#1}} 
\newcommand{\stopcols}{\end{columns}}

And tested with the habits.txt modification below

% Habits - Testing Multicol
% Barron
% 2016-05-05

# In the morning

## Getting up

\begincols{t}

\column{0.5\textwidth}

- Snooze alarm
- Roll over
- Snooze alarm
- Roll over
- Snooze alarm
- Roll over
- Snooze alarm
- Roll over

\column{0.5\textwidth}

- Turn off alarm
- Get out of bed

\stopcols

## Breakfast

- Eat ~~eggs~~ cereal
- Drink **coffee**

@kaspersoerensen
Copy link

kaspersoerensen commented Sep 7, 2016

That works well @barronh - but when using images in the columns it seems that the figure captions are removed. At least in the theme I am currently using. Might not apply to all themes/templates.

@trou
Copy link

trou commented Dec 21, 2016

I think this functionnality would be awesome. I've been using a python filter, but the problem lies in practice in block:

## Slide

[columns]

[column=0.5]

### block1

text

[column=0.5]

### block2

text2

[columns]

will generate the following latex code:

\begin{columns}
\column{0.5\textwidth}
\begin{block}{Block 1}
text
\column{0.5\textwidth}
\end{block}
\begin{block}{Block 2}
text2
\end{columns}
\end{block}

As you can see, pandoc doesn't close the first block before adding the column (of course).
Two ways this could be solved:

  • add a way for the python filter to close the current block (including updating the current pandoc state)
  • add column support in haskell

@jgm
Copy link
Owner

jgm commented Dec 24, 2016 via email

@trou
Copy link

trou commented Dec 25, 2016

That's an interesting workraround but it wouldn't allow for 2 different blocks in a columns

@jgm
Copy link
Owner

jgm commented Mar 9, 2017

I think the div option is good, but this should be implemented for HTML formats too.

@mb21
Copy link
Collaborator

mb21 commented Mar 9, 2017

I agree that the div with a class seems to be the right vehicle for inputting this (both in markdown input and AST).

For HTML output, there is also the option for auto-flowing the content of the div into columns, the necessary CSS (browser support includes IE>=11) would be either:

.column {
  column-count: 2;
}

or:

.column {
  column-width: 100px;
}

@barronh
Copy link

barronh commented Mar 9, 2017

The auto-flowing approach would need to be easily separated from the intentional flow. It is frequently the case that the left and right have intentional comparisons: pros vs cons; old results vs new results; etc.

The column-width approach does not work because the number of columns is not knowable and neither is the content. The column-count approach is better, but still the content of the columns cannot be specified.

@mb21
Copy link
Collaborator

mb21 commented Mar 9, 2017

It is frequently the case that the left and right have intentional comparisons: pros vs cons; old results vs new results; etc.

Right. Then we'd need something like:

<div class="columns">
  <div class="column">
    - my
    - pros
  </div>
  <div class="column">
    - my
    - cons
  </div>
</div>

ihrke added a commit to ihrke/markdown-talk that referenced this issue Aug 10, 2017
@jgm jgm closed this as completed in 892a4ed Aug 15, 2017
@HaoZeke
Copy link

HaoZeke commented Oct 29, 2017

Surely with CSS Grid columns are a cinch in HTML as well... SO maybe this should be looked at again?

@mb21
Copy link
Collaborator

mb21 commented Oct 29, 2017

@HaoZeke, this was implemented, see the commit referenced above

@henryiii
Copy link

henryiii commented Oct 30, 2017

@mb21 , I think @HaoZeke was looking at that comment, which shows it was added for LaTeX, and no other backends, like HTML. However, upon testing, the syntax in the release notes (almost) works.

Edit: The "closed in" commit is correct. It is just not as prominent as the other one.

There are two problems. The first is that the release note syntax has a 4 space indent, visually looks nice in the markdown but causes unformatted monospaced text.

The other problem is that blocks are not supported! So this fails to compile for beamer (failing hard, since the block is not closed):

<div class="columns">
<div class="column" width="40%">
## Block one
- Item
</div>
<div class="column" width="60%">
## Block two
- Item
</div>
</div>

@mb21
Copy link
Collaborator

mb21 commented Oct 31, 2017

@henryiii Have you looked at the discussion in #816 ? I think this is currently expected behaviour...

@henryiii
Copy link

@mb21 , I believe this is a different issue - the section level is something that's a bit odd, but I'm used to it. Pandoc produces non-valid LaTeX if you put a heading of any sort in a div, and I believe it doesn't ever produce blocks. I'll open dedicated issues.

@zedsmith52
Copy link

I have been trying to attempt something similar - the html file I have is test.html containing:

column1
column2
<style> .col { width: 40%; float: left; } </style>

Whatever I do, I cannot get pandoc to output two columns in docx or pdf.
I've tried tables, various css and although it works in html through a browser, pandoc just does not seem to be able to convert it.

On a side note, I also lose background images when I convert from html too.

Is this the same problem or something anyone has run into?

@henryiii
Copy link

Have you tried the pandoc 2 syntax? I use it heavily, but only tried it through the pdf output. (Use triple back ticks around what you are trying to keep github markdown from swallowing it up)

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

No branches or pull requests