nixvim-for-share/config/plugins/luasnip/snippets/tex/dcenvelope.lua
2025-07-26 12:43:01 +00:00

102 lines
3 KiB
Lua

local line_begin = require("luasnip.extras.expand_conditions").line_begin
return {
s(
{ trig = ";dcenvelope", dscr = "A LaTeX equation environment" },
fmta(
[[
% https://en.wikibooks.org/wiki/LaTeX/Letters#Envelopes
% https://tex.stackexchange.com/questions/268693/how-do-you-print-c4-envelopes
\documentclass{letter}
\usepackage{geometry}
\geometry{paperheight=9.25in,paperwidth=4.13in}
\usepackage{graphics}
\usepackage{envlab}
\usepackage[AutoFallBack=true]{xeCJK}
\setCJKmainfont<>
% from envlab
\SetEnvelope{9.25in}{4.13in}
% from envlab
\setlength{\ToAddressTopMargin}{0in} %Arbitrarily decided by me
% from envlab
\setlength{\ToAddressLeftMargin}{1in} %Arbitrarily decided by me
% from envlab
\makelabels
\begin{document}
\startlabels
% from envlab
\mlabel
{% This "%" is required to make alignment right
%
% Sender Address
%
% append \\ at the end of the line before inserting newline
%
% e.g. Title\\
% Address line1\\
% Address line2\\
% Address line3
<>
}
{% This "%" is required to make alignment right
%
% Reciever Address
%
% append \\ at the end of the line before inserting newline
%
% e.g. Title\\
% Address line1\\
% Address line2\\
% Address line3
<>
% if print with lpr use command "lpr -o media=EnvYou4"
}
\end{document}
]],
{
c(1, {
t({
"{Source Han Serif TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"{Source Han Sans TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]{SourceHanSerif.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
" ,UprightFeatures = {FontIndex=28}",
" ,BoldFeatures = {FontIndex=38}",
"]\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=28}",
",BoldFeatures = {FontIndex=38}",
"]{SourceHanSans.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
}),
i(3, "% Sender Address"),
i(2, "% Reciever Address"),
}
),
{ condition = line_begin } -- set condition in the `opts` table
),
}