1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[662],{37703:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>d,frontMatter:()=>o,metadata:()=>a,toc:()=>l});var s=n(85893),i=n(11151);const o={sidebar_position:45,description:"#alternatives has a couple of 'cousins' that might be more convenient in some situations.",toc_max_heading_level:2},r="alternatives-match",a={id:"reference/utils/alternatives-match",title:"alternatives-match",description:"#alternatives has a couple of 'cousins' that might be more convenient in some situations.",source:"@site/docs/reference/utils/alternatives-match.mdx",sourceDirName:"reference/utils",slug:"/reference/utils/alternatives-match",permalink:"/docs/reference/utils/alternatives-match",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:45,frontMatter:{sidebar_position:45,description:"#alternatives has a couple of 'cousins' that might be more convenient in some situations.",toc_max_heading_level:2},sidebar:"tutorialSidebar",previous:{title:"handout-only",permalink:"/docs/reference/utils/handout-only"},next:{title:"alternatives",permalink:"/docs/reference/utils/alternatives"}},c={},l=[{value:"subslides-contents : <TypeLink></TypeLink>",id:"subslides-contents",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:o,Parameters:r,Signature:a,SignatureName:c,SignatureParam:l,SourceLink:h,TypeLink:d}=t;return n||u("Default",!0),o||u("Param",!0),r||u("Parameters",!0),a||u("Signature",!0),c||u("SignatureName",!0),l||u("SignatureParam",!0),h||u("SourceLink",!0),d||u("TypeLink",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"alternatives-match",children:"alternatives-match"}),"\n",(0,s.jsx)(a,{children:(0,s.jsxs)("code",{children:[(0,s.jsx)(c,{children:"alternatives-match"}),"(",(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#self",children:"self: none"}),", "]}),(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#subslides-contents",children:"subslides-contents"}),", "]}),(0,s.jsxs)(l,{children:[(0,s.jsx)(t.a,{href:"#position",children:"position: bottom + left"}),", "]}),(0,s.jsx)(l,{children:(0,s.jsx)(t.a,{href:"#stretch",children:"stretch: false"})}),")",(0,s.jsx)(h,{href:"https://github.com/touying-typ/touying/blob/main/src/utils.typ#L2282"})]})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"#alternatives"}),' has a couple of "cousins" that might be more convenient in some situations. The first one is ',(0,s.jsx)(t.code,{children:"#alternatives-match"})," that has a name inspired by match-statements in many functional programming languages. The idea is that you give it a dictionary mapping from subslides to content:"]}),"\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-match((\n "1, 3-5": [this text has the majority],\n "2, 6": [this is shown less often]\n))\n'})}),"\n",(0,s.jsxs)(r,{children:[(0,s.jsxs)(t.h3,{id:"subslides-contents",children:["subslides-contents : ",(0,s.jsx)(d,{type:"dictionary"})]}),(0,s.jsx)(o,{children:(0,s.jsx)(t.p,{children:"A dictionary mapping from subslides to content."})}),(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)(o,{children:(0,s.jsxs)(t.p,{children:["The position of the content. 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)(o,{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 u(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:()=>a,a:()=>r});var s=n(67294);const i={},o=s.createContext(i);function r(e){const t=s.useContext(o);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(o.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.