PageSourceSearch

https://touying-typ.github.io/assets/js/59353ae6.80e748f5.js

js touying-typ.github.io collected 2026-10-03 10:08:54 UTC 5,221 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[6992],{6556:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>r,default:()=>d,frontMatter:()=>a,metadata:()=>c,toc:()=>l});var s=n(85893),i=n(11151);const a={sidebar_position:25,description:"You can use this function if you want to have one piece of content that changes only slightly depending of what 'case...",toc_max_heading_level:2},r="alternatives-cases",c={id:"reference/core/alternatives-cases",title:"alternatives-cases",description:"You can use this function if you want to have one piece of content that changes only slightly depending of what 'case...",source:"@site/docs/reference/core/alternatives-cases.mdx",sourceDirName:"reference/core",slug:"/reference/core/alternatives-cases",permalink:"/docs/reference/core/alternatives-cases",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:25,frontMatter:{sidebar_position:25,description:"You can use this function if you want to have one piece of content that changes only slightly depending of what 'case...",toc_max_heading_level:2},sidebar:"tutorialSidebar",previous:{title:"alternatives-fn",permalink:"/docs/reference/core/alternatives-fn"},next:{title:"item-by-item",permalink:"/docs/reference/core/item-by-item"}},o={},l=[{value:"cases : <TypeLink></TypeLink>",id:"cases",level:3},{value:"fn : <TypeLink></TypeLink>",id:"fn",level:3},{value:"position : <TypeLink></TypeLink> <Default><code>bottom + left</code></Default>",id:"position",level:3},{value:"stretch : <TypeLink></TypeLink> <Default><code>false</code></Default>",id:"stretch",level:3}];function h(e){const t={a:"a",code:"code",h1:"h1",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,i.a)(),...e.components},{Default:n,Param:a,Parameters:r,Signature:c,SignatureName:o,SignatureParam:l,SourceLink:h,TypeLink:d}=t;return n||f("Default",!0),a||f("Param",!0),r||f("Parameters",!0),c||f("Signature",!0),o||f("SignatureName",!0),l||f("SignatureParam",!0),h||f("SourceLink",!0),d||f("TypeLink",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"alternatives-cases",children:"alternatives-cases"}),"\n",(0,s.jsx)(c,{children:(0,s.jsxs)("code",{children:[(0,s.jsx)(o,{children:"alternatives-cases"}),"(",(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#cases",children:"cases"}),", "]}),(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#fn",children:"fn"}),", "]}),(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#position",children:"position: bottom + left"}),", "]}),(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#stretch",children:"stretch: false"}),", "]}),(0,s.jsx)(l,{children:(0,s.jsx)(t.a,{href:"#kwargs",children:"..kwargs"})}),")",(0,s.jsx)(h,{href:"https://github.com/touying-typ/touying/blob/main/src/core.typ#L2136"})]})}),"\n",(0,s.jsx)(t.p,{children:'You can use this function if you want to have one piece of content that changes only slightly depending of what "case" of subslides you are in.'}),"\n",(0,s.jsx)(t.p,{children:"Example:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-typst",children:'#alternatives-cases(("1, 3", "2"), case => [\n  #set text(fill: teal) if case == 1\n  Some text\n])\n'})}),"\n",(0,s.jsxs)(r,{children:[(0,s.jsxs)(t.h3,{id:"cases",children:["cases : ",(0,s.jsx)(d,{type:"array"})]}),(0,s.jsx)(a,{children:(0,s.jsx)(t.p,{children:"An array of strings that specify the subslides for each case."})}),(0,s.jsxs)(t.h3,{id:"fn",children:["fn : ",(0,s.jsx)(d,{type:"function"})]}),(0,s.jsx)(a,{children:(0,s.jsxs)(t.p,{children:["A function that maps the case to content. The argument ",(0,s.jsx)(t.code,{children:"case"})," is the index of the cases array you input."]})}),(0,s.jsxs)(t.h3,{id:"position",children:["position : ",(0,s.jsx)(d,{type:"alignment"})," ",(0,s.jsx)(n,{children:(0,s.jsx)(t.code,{children:"bottom + left"})})]}),(0,s.jsx)(a,{children:(0,s.jsxs)(t.p,{children:["The alignment of alternatives within the reserved space. Default is ",(0,s.jsx)(t.code,{children:"bottom + left"}),"."]})}),(0,s.jsxs)(t.h3,{id:"stretch",children:["stretch : ",(0,s.jsx)(d,{type:"bool"})," ",(0,s.jsx)(n,{children:(0,s.jsx)(t.code,{children:"false"})})]}),(0,s.jsx)(a,{children:(0,s.jsxs)(t.p,{children:["Whether to stretch all alternatives to the maximum width and height. Default is ",(0,s.jsx)(t.code,{children:"false"}),". Important: If you use a zero-length content like a context expression, you should set ",(0,s.jsx)(t.code,{children:"stretch: false"}),"."]})})]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Returns:"})," ",(0,s.jsx)(d,{type:"content"})]})]})}function d(e={}){const{wrapper:t}={...(0,i.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}function f(e,t){throw new Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}},11151:(e,t,n)=>{n.d(t,{Z:()=>c,a:()=>r});var s=n(67294);const i={},a=s.createContext(i);function r(e){const t=s.useContext(a);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(a.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.