Skip to content

Support setting .landscape class directly on a crossref div (e.g. to make a table in lanscape mode) #12420

Description

@eric-roca

Bug description

I am trying to provide my research articles both as html and pdf. Regarding the pdf generation, I am unable to combine referencing a table and placing it in landscape mode when raw latex is used.

Image

Image

Steps to reproduce

---
format:
  pdf:
    number-sections: true
    pdf-engine: tectonic
    pdf-engine-opts:
      - '--print'
    include-in-header:
      - text: |
          \usepackage{booktabs}
---

::: {.landscape #tbl-table}
```{=latex}
\begin{tabular}{lcccccccc}
&\multicolumn{8}{c}{Dep. variable: Lit. equality index, 1866} \\ \cmidrule(lr){2-8}
&\multicolumn{2}{c}{Baseline}         &\multicolumn{2}{c}{Fixed-effects}    &\multicolumn{2}{c}{Geography}        &\multicolumn{2}{c}{Monasteries}      \\
&\multicolumn{1}{c}{(1)}         &\multicolumn{1}{c}{(2)}         &\multicolumn{1}{c}{(3)}         &\multicolumn{1}{c}{(4)}         &\multicolumn{1}{c}{(5)}         &\multicolumn{1}{c}{(6)}         &\multicolumn{1}{c}{(7)}         &\multicolumn{1}{c}{(8)}         \\
\midrule
Beguinage (0/1)&    0.144         &                  &    0.153         &                  &    0.110         &                  &    0.101         &                  \\
          &  (0.019)***&                  &  (0.019)***&                  &  (0.026)***&                  &  (0.024)***&                  \\
          &  [0.019]***&                  &  [0.020]***&                  &  [0.027]***&                  &  [0.025]***&                  \\
Exposure (centuries)&                  &    0.021         &                  &    0.022         &                  &    0.014         &                  &    0.012         \\
          &                  &  (0.003)***&                  &  (0.003)***&                  &  (0.005)***&                  &  (0.005)***\\
          &                  &  [0.003]***&                  &  [0.003]***&                  &  [0.006]** &                  &  [0.006]** \\
\midrule
Fixed-effects&\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         \\
Geography &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         \\
Monasteries&\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         \\
Observations&\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2447}         &\multicolumn{1}{c}{2447}         &\multicolumn{1}{c}{2447}         &\multicolumn{1}{c}{2447}         \\
\(R^{2}\) &\multicolumn{1}{c}{0.030}         &\multicolumn{1}{c}{0.029}         &\multicolumn{1}{c}{0.203}         &\multicolumn{1}{c}{0.200}         &\multicolumn{1}{c}{0.231}         &\multicolumn{1}{c}{0.225}         &\multicolumn{1}{c}{0.235}         &\multicolumn{1}{c}{0.229}         \\
\end{tabular}
```
<figcaption style="text-align: left;">
<em>Note: </em>
    This table presents the results of OLS regressions relating the presence of beguinages to increased gender equality proxied by the variable $literacy\, equality\, index_{i(j}$, see main text for a description.
    Columns 1) and 2) include only the presence of beguinages as a regressor.
    Columns 3) and 4) add fixed-effects at the canton level.
    In Columns 5) and 6) exogenous variables are incorporated, namely, latitude, longitude, distance to Leuven, to large cities (defined in 1300), to the sea and rivers, caloric yield, soil type and crop productivity, province and arrondissement capital status as well as ruler fixed effects. All distances in log-km.
    Columns 7) and 8) further control for the presence of monasteries: masculine, feminine and unknown.
    From Column 5) onward, we always control for the total population during 1866.
    Standard errors clustered at the canton level in parenthesis and Conley standard errors, with a Bartlett kernel and a cut-off distance of 40 km, in brackets.
    ${}^{*}\, p < 0.1$, ${}^{**}\, p < 0.05$, ${}^{***}\, p < 0.01$.
</figcaption>

:::
</p>

Actual behavior

When both landscape and a reference are included, the page is in vertical model

Expected behavior

Rotate the page and get a reference

Your environment

IDE: quarto cli commands
OS: Arch Linux
Latex distribution: tectonic

Quarto check output

Quarto 1.7.6
[✓] Checking environment information...
Quarto cache location: /home/eric/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.4.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.46.3: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.7.6
Path: /opt/quarto/bin

[✓] Checking tools....................OK
Chromium: 869685
TinyTeX: (not installed)

[✓] Checking LaTeX....................OK
Tex: (not detected)

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
Version: 3.13.2
Path: /usr/bin/python3
Jupyter: 5.7.2
Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

  Unable to locate an installed version of R.
  Install R from https://cloud.r-project.org/

Activity

  1. mcanouil commented on Apr 1, 2025

    @mcanouil
    Collaborator

    Why do you have HTML markup?
    You probably should split ::: {.landscape #tbl-table} into two divs.
    You clearly should not have HTML markup outside of raw block and not at all if you are aiming at PDF/LaTeX.

    Also, if you use pre-releases, please keep your version up to date before opening issues.

    In the future, please use discussions when requesting help.

    InputOutput
    ---
    format: pdf
    ---
    
    ::: {.landscape}
    ::: {#tbl-table}
    
    ```{=latex}
    \begin{tabular}{|l|c|r|}
    \hline
    Column 1 & Column 2 & Column 3 \\ \hline
    Data 1   & Data 2   & Data 3   \\ \hline
    Data 4   & Data 5   & Data 6   \\ \hline
    \end{tabular}
    ```
    
    *Note:* {{< lipsum 1 >}}
    
    :::
    :::
    
    Image
  2. added
    supporta request for support
    and removed
    bugSomething isn't working
    on Apr 1, 2025
  3. eric-roca commented on Apr 1, 2025

    @eric-roca
    Author

    That was it, thank you!

  4. mcanouil commented on Apr 1, 2025

    @mcanouil
    Collaborator

    I edited my reply:

    In the future, please use discussions when requesting help.

    InputOutput
    ---
    format: pdf
    ---
    
    ::: {.landscape}
    ::: {#tbl-table}
    
    ```{=latex}
    \begin{tabular}{|l|c|r|}
    \hline
    Column 1 & Column 2 & Column 3 \\ \hline
    Data 1   & Data 2   & Data 3   \\ \hline
    Data 4   & Data 5   & Data 6   \\ \hline
    \end{tabular}
    ```
    
    *Note:* {{< lipsum 1 >}}
    
    :::
    :::
    
    Image
  5. cderv commented on Apr 1, 2025

    @cderv
    Member

    Trying to set .landscape on the same div is not surprising to me. 🤔

    I wonder if we could / should detect the .landscape class and handle it as if it were a div inside a div. This would be by convenience to support this syntax.

    Otherwise, maybe we should warn that .landscape was detected but is ignored.

    The only drawback I see is that it would make .landscape a "protected" class because it would be Quarto only, as we would warn or act when we see it. But this wouldn't be the first.

    Example something like

    Div = function(d)
        local _, i  = d.classes:find("landscape")
        if i and #d.classes > 0 then
            quarto.log.output("Found landscape div")
            d.classes:remove(i)
            return pandoc.Div(d, {'', {'landscape'} })
        end
    end
    ---
    format: pdf
    filters: 
      - path: landscape.lua
        at: pre-ast
    ---
    
    ::: {.landscape #tbl-table}
    
    ```{=latex}
    \begin{tabular}{|l|c|r|}
    \hline
    Column 1 & Column 2 & Column 3 \\ \hline
    Data 1   & Data 2   & Data 3   \\ \hline
    Data 4   & Data 5   & Data 6   \\ \hline
    \end{tabular}
    ```
    
    Table captions
    
    :::

    Regarding @mcanouil, you may have found a new issue when two captions are provided. See your screenshot, there is Table 1 and Table 2.

    Your example provide \begin{table} which is not adviced - Quarto will handle the table environment. The caption should be below and last element

    So I would give this example

    ---
    format: pdf
    ---
    
    ::: {.landscape}
    ::: {#tbl-table}
    
    ```{=latex}
    \begin{tabular}{|l|c|r|}
    \hline
    Column 1 & Column 2 & Column 3 \\ \hline
    Data 1   & Data 2   & Data 3   \\ \hline
    Data 4   & Data 5   & Data 6   \\ \hline
    \end{tabular}
    ```
    
    Sample Table
    
    :::
    
    *Note:* {{< lipsum 1 >}}
    
    :::

    which leads for @eric-roca to

    ---
    format: pdf
    ---
    
    ::: {.landscape}
    ::: {#tbl-table}
    
    ```{=latex}
    \begin{tabular}{lcccccccc}
    &\multicolumn{8}{c}{Dep. variable: Lit. equality index, 1866} \\ \cmidrule(lr){2-8}
    &\multicolumn{2}{c}{Baseline}         &\multicolumn{2}{c}{Fixed-effects}    &\multicolumn{2}{c}{Geography}        &\multicolumn{2}{c}{Monasteries}      \\
    &\multicolumn{1}{c}{(1)}         &\multicolumn{1}{c}{(2)}         &\multicolumn{1}{c}{(3)}         &\multicolumn{1}{c}{(4)}         &\multicolumn{1}{c}{(5)}         &\multicolumn{1}{c}{(6)}         &\multicolumn{1}{c}{(7)}         &\multicolumn{1}{c}{(8)}         \\
    \midrule
    Beguinage (0/1)&    0.144         &                  &    0.153         &                  &    0.110         &                  &    0.101         &                  \\
              &  (0.019)***&                  &  (0.019)***&                  &  (0.026)***&                  &  (0.024)***&                  \\
              &  [0.019]***&                  &  [0.020]***&                  &  [0.027]***&                  &  [0.025]***&                  \\
    Exposure (centuries)&                  &    0.021         &                  &    0.022         &                  &    0.014         &                  &    0.012         \\
              &                  &  (0.003)***&                  &  (0.003)***&                  &  (0.005)***&                  &  (0.005)***\\
              &                  &  [0.003]***&                  &  [0.003]***&                  &  [0.006]** &                  &  [0.006]** \\
    \midrule
    Fixed-effects&\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         &\multicolumn{1}{c}{Canton}         \\
    Geography &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         \\
    Monasteries&\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{No}         &\multicolumn{1}{c}{Yes}         &\multicolumn{1}{c}{Yes}         \\
    Observations&\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2549}         &\multicolumn{1}{c}{2447}         &\multicolumn{1}{c}{2447}         &\multicolumn{1}{c}{2447}         &\multicolumn{1}{c}{2447}         \\
    \(R^{2}\) &\multicolumn{1}{c}{0.030}         &\multicolumn{1}{c}{0.029}         &\multicolumn{1}{c}{0.203}         &\multicolumn{1}{c}{0.200}         &\multicolumn{1}{c}{0.231}         &\multicolumn{1}{c}{0.225}         &\multicolumn{1}{c}{0.235}         &\multicolumn{1}{c}{0.229}         \\
    \end{tabular}
    ```
    
    Sample Table
    
    :::
    
    *Note:* {{< lipsum 1 >}}
    
    :::

    Image

  6. changed the title [-]Raw latex table, landscape mode and reference[/-] [+]Support setting .landscape class directly on a crossref div (e.g. to make a table in lanscape mode)[/+] on Apr 1, 2025
  7. added
    tablesIssues with Tables including the gt integration
    enhancementNew feature or request
    and removed
    supporta request for support
    on Apr 1, 2025
  8. added this to the Future milestone on Apr 1, 2025
  9. cderv commented on Apr 1, 2025

    @cderv
    Member

    I am reopening to consider and discuss the feature request for this syntax

    ---
    format: pdf
    ---
    
    ::: {.landscape #tbl-table}
    
    | A | B |
    |---|---|
    | C | D |
    
    Table caption
    
    :::
  10. reopened this on Apr 1, 2025
  11. mcanouil commented on Apr 1, 2025

    @mcanouil
    Collaborator

    @cderv Indeed, I reused quickly one of my default "example" for LaTeX raw code. I did not picked the correct one. Since that is a misuse, I don't know if we should consider this a bug which is very specific to LaTeX. (I edited to avoid mis-direction of future readers)

    About considering this a feature request, I believe it's more general than that.
    Should any "layout div" be allowed to be merged with cross-reference divs? (there are other issues about this)

  12. mcanouil commented on Apr 1, 2025

    @mcanouil
    Collaborator

    Conceptually, I find it very weird to merge content with page layout specification.
    .landscape define the orientation of the page in most formats, not the orientation of the content.

  13. added and removed
    tablesIssues with Tables including the gt integration
    on Apr 1, 2025
  14. cscheid commented on Apr 1, 2025

    @cscheid
    Member

    @cderv We need to be pretty careful with designs like this. The general problem is that the order of resolution becomes complicated when features interact. For example, consider the following:

    ::: {.column-page .landscape #tbl-1}
    
    ... table
    
    ... caption
    
    :::
    

    How should this be interpreted? As

    ::: {.column-page .landscape}
    
    ::: {#tbl-1}
    
    ... table
    
    ... caption
    
    :::
    
    :::
    

    or

    ::: {#tbl-1}
    
    ::: {.column-page .landscape}
    
    ... table
    
    ... caption
    
    :::
    
    :::
    

    Note that the latter is now not actually working as intended because of the caption inside a div.

    (Our current designs actually handle this specific case correctly. But every time there's feature ordering involved, an n-way interaction becomes at least exponentially complicated, because there are n! different ways to order the expression.)

  15. cderv commented on Apr 1, 2025

    @cderv
    Member

    Ok I see. Let's not do that then.

    We should focus on helping / guiding users to use the right syntax.

    Another linting problem when we could detect .landscape with other classes on a div and add an indication this should be on its own div ?

    I guess I am acknowledging the confusion of

    • Which class needs to be on its own div ?
    • Which class can be used on the same div as others ?

    Not that straightfoward to users. For me two paths:

    • Support multiple syntax (but you explain this is not a good idea)
    • Being proactive in helping user use the right syntax.

    Thanks for the explanation!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions