#show rules in external file

12 messages · Page 1 of 1 (latest)

wet plume
#

Hi, how I can import a file with show rules inside of him and make use of that?

fierce schooner
#

You can't import show rules directly, but you can create a function that takes some content and applies the rules to it. For example, in one file you have

#let red-text(content) = {
  show text: set text(red)
  content
}

then you import that function in another file and just write

#red-text[Hi there]

wet plume
fierce schooner
#
#let my-codeblock(code) = {
  show raw.where(block: true): it => {
    set align(left)
    set block(fill: luma(240), inset: 10pt, radius: 4pt)
    it
  }
  code
}

and then

#my-codeblock[

keys_list = ['A', 'B', 'C']
values_list = ['blue', 'red', 'bold']

#There are 3 ways to convert these two lists into a dictionary
#1- Using Python's zip, dict functionz
dict_method_1 = dict(zip(keys_list, values_list))
```
]
#

oops hold on

#

well I cant properly display it, but you get the idea

#

like this

wet plume
#

got it thanks!
I have another question, how i can work with multiple files for writing and merge them using main?

fierce schooner
#

just write #include 'file.typ' and everything that is dispalyed in file will be displayed here as well

wet plume
#

thanks again main you are a life-saver!