Is it possible to add a breakable
for cross referenced Code Block?
#8527
-
DescriptionHello everyone I'm in a bit of a pickle. After resolving #8519 , I'm trying to solve the next problem. The goal is to have a cross referenced, syntax highlighted code block which is multiple pages long. Right now, to have the syntax highlighting AND be cross referenced, the code block is put inside a cross referenced div. Now is it possible to adjust the ---
title: syntax
format:
pdf:
pdf-engine: pdflatex
include-in-header:
- text: "\\usepackage{blindtext}"
---
:::{#lst-hello2}
```cpp
int8_t hello;
int8_t add(int8_t a, int8_t b);
int8_t subtract(int8_t a, int8_t b);
void main(void) {
hello = 1;
while(true) {
hello++;
if(hello=10) {
hello = 0;
}
}
}
int8_t add(int8_t a, int8_t b) {
return a + b;
}
int8_t subtract(int8_t a, int8_t b) {
return a - b;
}
int8_t hello;
int8_t add(int8_t a, int8_t b);
int8_t subtract(int8_t a, int8_t b);
void main(void) {
hello = 1;
while(true) {
hello++;
if(hello=10) {
hello = 0;
}
}
}
int8_t add(int8_t a, int8_t b) {
return a + b;
}
int8_t subtract(int8_t a, int8_t b) {
return a - b;
}
int8_t hello;
int8_t add(int8_t a, int8_t b);
int8_t subtract(int8_t a, int8_t b);
void main(void) {
hello = 1;
while(true) {
hello++;
if(hello=10) {
hello = 0;
}
}
}
int8_t add(int8_t a, int8_t b) {
return a + b;
}
int8_t subtract(int8_t a, int8_t b) {
return a - b;
}
int8_t hello;
int8_t add(int8_t a, int8_t b);
int8_t subtract(int8_t a, int8_t b);
void main(void) {
hello = 1;
while(true) {
hello++;
if(hello=10) {
hello = 0;
}
}
}
int8_t add(int8_t a, int8_t b) {
return a + b;
}
int8_t subtract(int8_t a, int8_t b) {
return a - b;
}
```
Hello #2
:::
```{=latex}
\blindtext
\blindtext
```
@lst-hello2 Example of the end useWhat I like to have (with cross referencing) I know this behavior is due to the usage of a float environment, but is there a possible workaround? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
That's a LaTeX question. I am not even sure it's possible in plain LaTeX with the current output. |
Beta Was this translation helpful? Give feedback.
-
As far as I can tell, it's not. page-spanning environments in LaTeX are complicated (there's |
Beta Was this translation helpful? Give feedback.
-
Ah okay, that makes sense. I've found a workaround for now. By creating an empty cross reference div, remove a bit of vertical spacing between the caption and the code block and add the caption into the div-information, I kind of get what I wanted! :::{#lst-hello2 lst-cap="hello"}
:::
`\vspace{-4mm}`{=latex}
```cpp
...
``` |
Beta Was this translation helpful? Give feedback.
As far as I can tell, it's not. page-spanning environments in LaTeX are complicated (there's
longtable
for tables and that by itself introduces a ton of extra complications in the typesetting)