├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── diagbox.typ └── examples ├── example.pdf └── example.typ /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 PgBiel 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Pg Biel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # typst-diagbox 2 | A library for diagonal line dividers in Typst tables; a.k.a., 3 | table cells with a diagonal line dividing them. 4 | 5 | ## Usage 6 | 7 | Move the `diagbox.typ` file to e.g. the same folder 8 | your main `.typ` file is in, then write 9 | `#import "diagbox.typ": *` inside it. 10 | 11 | This will import two functions: 12 | `bdiagbox[left][right]` (for a diagonal from top-left 13 | to bottom-right) and `tdiagbox[left][right]` (for a 14 | diagonal line from bottom-left to top-right). 15 | 16 | See sample usage in the `examples` folder. 17 | 18 | ![image](https://user-images.githubusercontent.com/9021226/227755001-a3a8b865-3de9-45be-869f-1ba755133f55.png) 19 | 20 | 21 | ## How it works 22 | 23 | Using a simple box with a diagonal line across it won't work in 24 | most cases, as `table`s come with an internal padding option 25 | called `inset`; thus, no box would be able to occupy an entire 26 | cell (there would always be some negative space around it). 27 | 28 | Instead, the `bdiagbox` and `tdiagbox` functions take an `inset` 29 | parameter (which defaults to `5pt`, the default for all tables, 30 | but must be overridden if your table has a different value). 31 | With that parameter, the diagonal line will exceed the box's 32 | boundaries to compensate for the padding. 33 | 34 | So, for example, if we consider a coordinate system with `(0, 0)` 35 | as the inner box's top left corner, with `x` increasing to the right 36 | and `y` increasing downwards, we would have, for `bdiagbox` 37 | (a diagonal line going from top left to bottom right), 38 | a line going from `(-inset, -inset)` to 39 | `(inner_width + inset, inner_width + inset)`, where 40 | `inner_width` is calculated (normally) by `width - 2*inset` 41 | (where `width` is the column's total width, which the diagbox 42 | should fully occupy). 43 | 44 | ## License 45 | 46 | Licensed under MIT or Apache-2.0, at your option. 47 | 48 | This is why, if you place a diagbox outside of a table 49 | without specifying `inset: 0pt`, with `box_stroke: 1pt`, you will 50 | notice that the line "overflows" the box - this is necessary to 51 | compensate for internal table padding. 52 | -------------------------------------------------------------------------------- /diagbox.typ: -------------------------------------------------------------------------------- 1 | /** 2 | * A diagonal box going from top left to bottom right. (The right-most position determines the prefix.) 3 | * Note: If using this outside of a table, setting inset to '0pt' is recommended. 4 | * 5 | * 'text_left' is the text that appears at the bottom left; 6 | * 'text_right', at the top right; 7 | * 'width' is the total width the diag box should span. Specify the table's column width 8 | * in this option; 9 | * 'inset' is the inset (inner cell padding) of the table - defaults to 5pt (just like tables do). Set 10 | * this to 0pt if not inside a table; 11 | * 'text_pad' is the general inner padding applied to text, which makes it move more 'inside'. It is used, 12 | * with negative values, to 'counter' a table's inner padding (inset). By default, it follows the 13 | * formula '-2 * inset/3 + 3pt', which covers both low insets (with the 3pt) and 14 | * high insets (due to '-2 * inset/3'). Setting this option shouldn't normally be necessary. 15 | * 'box_stroke' optionally gives a border to the box (e.g., if outside a table) - defaults to 'none' 16 | * (uses the table's cell rendering), but you may write, e.g., `teal + 1pt`, `yellow`, `3pt` etc. 17 | * 'line_stroke' optionally controls the diagonal line's color and stroke size, with, for example, 18 | * `yellow + 2pt`, `blue`, `3pt` etc. Defaults to `1pt`. 19 | * 20 | * Additional options: 21 | * 'inner_width' overrides width calculation of the inner box (the width of the diagbox, 22 | * not considering the table's 'inset' padding). The default formula for inner width is 23 | * 'width - 2*inset', if column width is specified; otherwise, it simply measures the width 24 | * of the given texts: '2*calc.max(left, right)'. You shouldn't generally need to change this 25 | * option. 26 | * 'left_sep', 'right_sep' define the distance of the bottom left and top right texts to their nearest 27 | * respective vertical borders (they move those texts horizontally, away from the nearest border) - 28 | * they default to 0pt, and may be negative to move in the opposite direction; 29 | * 'left_outer_sep', 'right_outer_sep' define where the diagonal line starts and ends, respectively. 30 | * They move each end of the line horizontally, away from the nearest vertical border, and may 31 | * be negative. 32 | */ 33 | #let bdiagbox( 34 | text_left, text_right, 35 | width: none, height: none, 36 | inset: 5pt, text_pad: none, 37 | box_stroke: none, line_stroke: 1pt, 38 | inner_width: none, 39 | left_sep: 0pt, right_sep: 0pt, 40 | left_outer_sep: 0pt, right_outer_sep: 0pt, 41 | ) = context { 42 | let left_measure = measure(text_left) 43 | let right_measure = measure(text_right) 44 | 45 | let text_pad = if text_pad == none { 46 | // some adjusting; sum 3pt for the base case (5pt) 47 | // for larger insets, it isn't very relevant 48 | -2*inset/3 + 3pt 49 | } else { 50 | text_pad 51 | } 52 | 53 | let height = if height != none { 54 | height 55 | } else { 56 | 2*(left_measure.height + right_measure.height) 57 | } 58 | 59 | let inner_width = if inner_width != none { 60 | inner_width 61 | } else if width != none { 62 | width - 2*inset 63 | } else { 64 | 2*calc.max(left_measure.width, right_measure.width) 65 | } 66 | 67 | box(width: inner_width, height: height, stroke: box_stroke)[ 68 | #show line: place.with(top + left) 69 | #place(top + right, move(dx: -right_sep - text_pad, dy: text_pad, text_right)) 70 | #line(start: (left_outer_sep - inset, -inset), end: (inner_width + inset - right_outer_sep, height + inset), stroke: line_stroke) 71 | #place(bottom + left, move(dx: left_sep + text_pad, dy: -text_pad, text_left)) 72 | ] 73 | } 74 | 75 | /** 76 | * Same as 'bdiagbox', but with the line going from bottom left to top right. Thus, 77 | * 'text_left' goes on the top left, while 'text_right' goes on the top right, 78 | * and the corresponding options affect the equivalent parameters (left -> `text_left`, 79 | * right -> `text_right`). 80 | */ 81 | #let tdiagbox( 82 | text_left, text_right, 83 | width: none, height: none, 84 | inset: 5pt, text_pad: none, 85 | box_stroke: none, line_stroke: 1pt, 86 | inner_width: none, 87 | left_sep: 0pt, right_sep: 0pt, 88 | left_outer_sep: 0pt, right_outer_sep: 0pt, 89 | ) = context { 90 | let left_measure = measure(text_left) 91 | let right_measure = measure(text_right) 92 | 93 | let text_pad = if text_pad == none { 94 | // some adjusting; sum 3pt for the base case (5pt) 95 | // for larger insets, it isn't very relevant 96 | -2*inset/3 + 3pt 97 | } else { 98 | text_pad 99 | } 100 | 101 | let height = if height != none { 102 | height 103 | } else { 104 | 2*(left_measure.height + right_measure.height) 105 | } 106 | 107 | let inner_width = if inner_width != none { 108 | inner_width 109 | } else if width != none { 110 | width - 2*inset 111 | } else { 112 | 2*calc.max(left_measure.width, right_measure.width) 113 | } 114 | 115 | box(width: inner_width, height: height, stroke: box_stroke)[ 116 | #show line: place.with(top + left) 117 | #place(top + left, move(dx: left_sep + text_pad, dy: text_pad, text_left)) 118 | #line(start: (left_outer_sep - inset, height + inset), end: (inner_width + inset - right_outer_sep, -inset), stroke: line_stroke) 119 | #place(bottom + right, move(dx: -right_sep - text_pad, dy: -text_pad, text_right)) 120 | ] 121 | } 122 | 123 | // TODO: Add function for two diagonal lines (for a third text option, in the middle). 124 | -------------------------------------------------------------------------------- /examples/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PgBiel/typst-diagbox/516bae2cc8040e0546948059e75d6d3368dc21c1/examples/example.pdf -------------------------------------------------------------------------------- /examples/example.typ: -------------------------------------------------------------------------------- 1 | #import "../diagbox.typ": * 2 | 3 | Using `auto` columns is very convenient when it is the largest cell 4 | in that column: 5 | 6 | ```typ 7 | #table( 8 | columns: (auto, auto, auto), 9 | align: horizon + center, 10 | bdiagbox[Names][Properties], [*Can Walk*], [*Can Run*], 11 | [*Character A*], [Yes], [No], 12 | [*Character B*], [No], [No] 13 | ) 14 | ``` 15 | 16 | #table( 17 | columns: (auto, auto, auto), 18 | align: horizon + center, 19 | bdiagbox[Names][Properties], [*Can Walk*], [*Can Run*], 20 | [*Character A*], [Yes], [No], 21 | [*Character B*], [No], [No] 22 | ) 23 | 24 | \ 25 | Note that this fails when the diagbox is not the largest cell: 26 | 27 | ```typ 28 | #table( 29 | columns: (auto, auto, auto), 30 | align: horizon + center, 31 | bdiagbox[Names][Properties], [*Can Walk*], [*Can Run*], 32 | [*Long Long Long Character A*], [Yes], [No], 33 | [*Long Long Long Character B*], [No], [No] 34 | ) 35 | ``` 36 | 37 | #table( 38 | columns: (auto, auto, auto), 39 | align: horizon + center, 40 | bdiagbox[Names][Properties], [*Can Walk*], [*Can Run*], 41 | [*Long Long Long Character A*], [Yes], [No], 42 | [*Long Long Long Character B*], [No], [No] 43 | ) 44 | \ 45 | Instead, you will have to specify sizes manually in such cases: 46 | 47 | ```typ 48 | #let fst_column_size = 15em; 49 | #table( 50 | columns: (fst_column_size, auto, auto), 51 | align: horizon + center, 52 | bdiagbox(width: fst_column_size)[Names][Properties], [*Can Walk*], [*Can Run*], 53 | [*Long Long Long Character A*], [Yes], [No], 54 | [*Long Long Long Character B*], [No], [No] 55 | ) 56 | ``` 57 | 58 | #[ 59 | #let fst_column_size = 15em; 60 | #table( 61 | columns: (fst_column_size, auto, auto), 62 | align: horizon + center, 63 | bdiagbox(width: fst_column_size)[Names][Properties], [*Can Walk*], [*Can Run*], 64 | [*Long Long Long Character A*], [Yes], [No], 65 | [*Long Long Long Character B*], [No], [No] 66 | ) 67 | ] 68 | 69 | You can also have diagonal lines pointing in the opposite direction, using `tdiagbox`: 70 | 71 | #block(breakable: false)[```typ 72 | #let third_column_size = 5em; 73 | #table( 74 | columns: (auto, auto, third_column_size), 75 | align: horizon + center, 76 | bdiagbox[Names][Properties], [*Can Walk*], [*Can Run*], 77 | [*Character A*], [Yes], [No], 78 | [*Character B*], [No], tdiagbox(width: third_column_size)[A][B] 79 | ) 80 | ```] 81 | 82 | #[ 83 | #let third_column_size = 5em; 84 | #table( 85 | columns: (auto, auto, third_column_size), 86 | align: horizon + center, 87 | bdiagbox[Names][Properties], [*Can Walk*], [*Can Run*], 88 | [*Character A*], [Yes], [No], 89 | [*Character B*], [No], tdiagbox(width: third_column_size)[A][B] 90 | ) 91 | ] 92 | 93 | 94 | If your table has a custom `inset` (inner padding) property, make sure to pass it along: 95 | 96 | ```typ 97 | #let third_column_size = 5em; 98 | #let inset = 20pt; 99 | #table( 100 | columns: (auto, auto, third_column_size), 101 | align: horizon + center, 102 | inset: inset, 103 | bdiagbox(inset: inset)[Names][Properties], [*Can Walk*], [*Can Run*], 104 | [*Character A*], [Yes], [No], 105 | [*Character B*], [No], tdiagbox(inset: inset, width: third_column_size)[A][B] 106 | ) 107 | ``` 108 | 109 | #[ 110 | #let third_column_size = 5em; 111 | #let inset = 20pt; 112 | #table( 113 | columns: (auto, auto, third_column_size), 114 | align: horizon + center, 115 | inset: inset, 116 | bdiagbox(inset: inset)[Names][Properties], [*Can Walk*], [*Can Run*], 117 | [*Character A*], [Yes], [No], 118 | [*Character B*], [No], tdiagbox(inset: inset, width: third_column_size)[A][B] 119 | ) 120 | ] 121 | 122 | You may specify a standalone (table-less) diagbox with `inset: 0pt` 123 | and `box_stroke: 1pt`: 124 | 125 | ```typ 126 | #bdiagbox(inset: 0pt, box_stroke: 1pt)[Part A][Part B] 127 | ``` 128 | 129 | #bdiagbox(inset: 0pt, box_stroke: 1pt)[Part A][Part B] 130 | 131 | Additionally, diagboxes have many more properties 132 | which enable near-full customization. Most were inspired 133 | by the `diagbox` LaTeX package. 134 | 135 | For example, you may customize the box and line colors and sizes: 136 | 137 | ```typ 138 | #bdiagbox( 139 | inset: 0pt, 140 | box_stroke: teal + 3pt, line_stroke: yellow + 2pt 141 | )[Part A][Part B] 142 | ``` 143 | 144 | #bdiagbox( 145 | inset: 0pt, 146 | box_stroke: teal + 3pt, line_stroke: yellow + 2pt 147 | )[Part A][Part B] 148 | 149 | Use `left_sep` and `right_sep` to move text horizontally 150 | without resizing the box: 151 | 152 | ```typ 153 | #bdiagbox( 154 | width: 10em, 155 | inset: 0pt, box_stroke: 1pt, // standalone 156 | left_sep: 3em, right_sep: -0.5em 157 | )[Part A][Part B] 158 | ``` 159 | 160 | #bdiagbox( 161 | width: 10em, 162 | inset: 0pt, box_stroke: 1pt, 163 | left_sep: 3em, right_sep: -0.5em 164 | )[Part A][Part B] 165 | 166 | Use `left_outer_sep` and `right_outer_sep` to move the diagonal line 167 | horizontally (its start and its end, respectively): 168 | 169 | ```typ 170 | #tdiagbox( 171 | width: 10em, 172 | inset: 0pt, box_stroke: 1pt, // standalone 173 | left_outer_sep: 1.5em, right_outer_sep: 4em 174 | )[Part A][Part B] 175 | ``` 176 | 177 | #tdiagbox( 178 | width: 10em, 179 | inset: 0pt, box_stroke: 1pt, 180 | left_outer_sep: 1.5em, right_outer_sep: 4em 181 | )[Part A][Part B] 182 | 183 | Also note that the box's inner width (that is, total width minus 184 | inset padding) is calculated with `width - 2*inset`; you may specify 185 | the `inner_width` parameter to override that. 186 | (But you will generally want to specify just `width`, as it corresponds 187 | directly to the width of the table column the diagbox is in.) 188 | 189 | You can also use `height` if you want to define a custom, fixed height 190 | for your box: 191 | 192 | ```typ 193 | #tdiagbox( 194 | width: 10em, height: 5em, 195 | inset: 0pt, box_stroke: 1pt, // standalone 196 | )[Part A][Part B] 197 | ``` 198 | 199 | #tdiagbox( 200 | width: 10em, height: 5em, 201 | inset: 0pt, box_stroke: 1pt, // standalone 202 | )[Part A][Part B] 203 | --------------------------------------------------------------------------------