Sagittarius Rover
Sagittarius Rover
我要成为Typst糕手/(ㄒoㄒ)/~~

注册于 2年前

回答
278
文章
0
关注者
11

随缘改了下...

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\definecolor{bg@main}{RGB}{254,216,71}
\definecolor{bg@second}{RGB}{249,241,179}
\definecolor{bg@third}{RGB}{247,234,156}
\definecolor{text@main}{RGB}{254,216,71}
\definecolor{text@second}{RGB}{2,49,102}
\definecolor{text@third}{RGB}{162,148,65}
\usepackage[paperwidth=16.51cm, paperheight=24.77cm]{geometry}
\def\maketitle{%
    \newgeometry{margin=0pt}
    \begin{titlepage}
        \begin{tikzpicture}[remember picture, overlay]
            \def\textnode[##1]##2;{%
                \node[anchor=west, align=left, ##1] ##2;
            }
            \fill[left color=bg@second] (current page.north west) rectangle (current page.south east);
            \fill[bg@main] (current page.south east) rectangle ++(-0.9\paperwidth, 0.69\paperheight) coordinate (t1);
            \fill[bg@third] (t1) rectangle ++(-0.1\paperwidth, -0.137\paperheight);
            
            \draw[white, very thick] (current page.north west) ++ (.1\paperwidth, 0) -- ++ (0, -\paperheight);
            \draw[white, very thick] (current page.north west) ++ (0, -.31\paperheight) -- ++ (\paperwidth, 0);
            \draw[white, very thick] (current page.north west) ++ (0, -.447\paperheight) -- ++ (.1\paperwidth, 0);
            
            \textnode[text=text@third, font=\LARGE] at ([xshift=0.1\paperwidth + 0.75cm, yshift=-0.75cm]current page.north west) {Graduate Text in Mathematics};
            \textnode[text=text@main, scale=5, anchor=north east] at (current page.north east) {GTM};
            \textnode[text=text@second, anchor=south west, scale=2.4] at ([xshift=0.75cm]t1) {Mathematician Analysis};
            \textnode[text=text@second, anchor=north west, scale=7] at ([xshift=0cm]t1) {Introduction \\ to Real \\ Analysis};
            % 插入自定义图片并调整
            \node[anchor=south east] at ([shift={(-1cm,1cm)}]current page.south east) {%
                \begin{minipage}[b][1.5cm][c]{2cm}
                    \hfill\includegraphics[width=1.5\linewidth]{springer_horse.png}
                \end{minipage}%
                \begin{minipage}[b][1.5cm][c]{3cm}
                    \centering \huge\bfseries Springer
                \end{minipage}
            };
        \end{tikzpicture}
    \end{titlepage}
    \restoregeometry
}
\begin{document}
    \maketitle
\end{document}
  • 如果你不懂,就不要乱改别人的参数,在参考链接中明明是:
\def\textnode[##1]##2;{%
                \node[anchor=west, align=left, ##1] ##2;%
            }%

怎么到你这里一抄就变成了#1#2(?)你能解释解释吗...

  • 请自行学习tikznode的用法
  • 同时再自行学习minipage环境的用法

image.png

不会markdown语法不要提问。

P.S. markdown语法是很重要的,问题描述也要完整,清楚

P.S. 遇到报错最好附上报错信息(给你补上了),更容易被其他人检索到关键词。

  • \tikzset不需要;
\tikzset{
            declare function={
                f(\x)=cos(\x r);
                g(\x)=\fpeval{1/3};
                h(\x)=-0.5;
            }
        };
  • 参照文档好像是更快的办法...

image.png

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,intersections}
\begin{document} 
    \begin{tikzpicture}
        \tikzset{
            declare function={
                f(\x)=cos(\x r);
                g(\x)=\fpeval{1/3};
                h(\x)=-0.5;
            }
        }
        \draw[-Stealth] ({-2.1*pi},0)--({2.2*pi},0)node[below]{$x$};
        \draw[-Stealth] (0,-1.5)--(0,1.5)node[left]{$y$};
        \draw[name path=s,domain=-2*pi:2*pi,samples=600] plot (\x,{f(\x)});
        \draw[name path=l,color=cyan,domain=-2*pi:2*pi,samples=600] plot (\x,{g(\x)});
        \draw[name path=ll,color=cyan,domain=-2*pi:2*pi,samples=600] plot (\x,{h(\x)});
        \fill[name intersections={of=s and l,name=P,total=\t}] 
             [color=red] \foreach \i in {1,...,\t}{(P-\i) circle (1pt) node[above] {$\i$}};
    \end{tikzpicture}
\end{document}

image.png

有一点改善,但没有完全解决:

提供一个related issues

也许可供参考(?)但其实问题并没有解决...感觉应该在哪里reported过

\documentclass[aspectratio=169]{beamer}
\usepackage[noindent]{ctexcap}
\usepackage{amsfonts, amsmath}
\usetheme{Madrid}
\usecolortheme{default}
\usefonttheme{professionalfonts}
% \usefonttheme[onlymath]{serif}
% \AtBeginDocument{%
%     \DeclareSymbolFont{pureletters}{T1}{\mathfamilydefault}{\mddefault}{it}%
%     }
\begin{document}
\begin{frame}
    $\dot{H}^{1/2}$
\end{frame}
\end{document}

image.png

Edit:

SwitWu老师 @u20011 指出,使用unicode-math可以有效解决这一问题:

image.png

有关math accent与beamer的爱恨情仇,还可见:这个链接

请按照这个链接的操作确定这是什么字体。或者提供单页的PDF文件作为示例。

related link

\documentclass{beamer}
\usetheme{Berlin}
\usepackage{ctex}
\usepackage{amsmath}
\usefonttheme{serif}
\usepackage{cleveref}
\usepackage{hyperref}
\crefformat{equation}{#2式~(#1#3)}

\let\chyperref\cref
\renewcommand{\cref}[1]{{\hyperlink{#1}{\chyperref{#1}}}}

\begin{document}

\section{问题重述}
\begin{frame}{问题重述}
    这是上帝公式
    \begin{equation}
        \mathrm{e}^{\mathrm{i}\pi}+1=0
        \label{eq:1}
    \end{equation}
\end{frame}

\begin{frame}
    \cref{eq:1}是最美的公式。
\end{frame}

\end{document}

另外,原始MWE带来的警告与这个问题似乎是相同的...

The beamer document class redefines the \label command in a particularly devious way...

我觉得你不应该用计数器proof以及\theproof的值来控制长度。

另外我没看懂『前后无间距以使得悬挂缩进可以实现』,以及subsize是想实现什么...

如果你需要『悬挂缩进』,其实latex2e是有类似的quote环境的:

image.png

%article.cls
\newenvironment{verse}
               {\let\\\@centercr
                \list{}{\itemsep      \z@
                        \itemindent   -1.5em%
                        \listparindent\itemindent
                        \rightmargin  \leftmargin
                        \advance\leftmargin 1.5em}%
                \item\relax}
               {\endlist}
\newenvironment{quotation}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item\relax}
               {\endlist}
\newenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item\relax}
               {\endlist}

另外,代码要给完整...同时最好详细描述proof以及subsize想达到的预期效果示意图。

提供代码要完整,可编译。

一个也许你的复现如下:

\documentclass{article}
\usepackage[a4paper,showframe]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{xcolor}
\begin{document}
\begin{figure}[h]
    \centering
    \caption[Sparse-SIM resolves known structures of ~60 nm in size.]{Sparse-SIM resolves known structures of ~60 nm in size.}
    \includegraphics[width=.6\linewidth]{example-image}
    \begin{minipage}{\textwidth}
    {\color{red}\textbf{This is the table notes}}\\
    \lipsum[1-6]%
    \end{minipage}
\end{figure}
\end{document}

image.png

那你确实要么只能缩小字体,要么只能压缩内容。

提问必须提供完整的MWE。

确实如此,请查看texdoc amsthm的文档。

image.png

\documentclass{article}
\usepackage{amsthm}
\newtheorem{mythmA}{ThmA}
\theoremstyle{definition}
\newtheorem{mythmB}{ThmB}
\setlength{\parindent}{0pt}
\begin{document}

This is a theorem with a custom label.

\begin{mythmA}
This is a theorem with a custom label.
\end{mythmA}

\begin{mythmB}
This is a theorem with a custom label.
\end{mythmB}

This is a theorem with a custom label.

\end{document}

image.png

考古....

一个比较方便的办法是使用paracol提供的\columnratio{.6667}:

\documentclass{article}
\usepackage{microtype}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{paracol}
\usepackage{lipsum}
\usepackage{graphicx}
\columnratio{.6667}

\begin{document}

\begin{paracol}{2}
\lipsum[1-5]
\switchcolumn
\lipsum[1]

\noindent\includegraphics[width=5cm]{example-image}

\lipsum[2]
\end{paracol}

\end{document}

image.png

提问必须要给最小工作示例

希望上下两行的能够换行的答题线长度之和是定值,暂定为9em,考虑到通用性,希望可以指定任意合理的长度

不完全符合OP的需求,但也许可以借用xeCJkfntef提供的hidden选项,用多个之间的间隙来实现自动换行。

\documentclass{ctexart}
\usepackage[showframe,margin=1in]{geometry}
\usepackage{enumitem}
\setlist[enumerate]{nosep,labelsep=0pt,leftmargin=2em}
\usepackage{multicol}
\setlength{\columnseprule}{.4pt}
\setlength{\columnsep}{1cm}
\usepackage{xeCJKfntef}
\newcommand{\gentext}[2][啊]{%
    \ifnum#2>0\relax%
        #1\gentext{\numexpr#2-1}\unskip%
    \fi%
}
\newcommand*{\myrule}[2][.4pt]{%
    \CJKunderline[hidden,thickness=#1]{\gentext{#2},\gentext{#2}}
}
\begin{document}

\noindent\textbf{16. }补写出下列句子中的空缺部分。(6分)

\begin{multicols}{2}

\begin{enumerate}[label=(\arabic{enumi})]
    \item 
    王湾《次北固山下》的名句“\myrule{5}”,描写时序交替中的景物,暗示着时光流逝,蕴含着自然理趣。
    \item 
    小慧为朋友家的农家乐餐厅写宣传横幅,直接使用了陆游《游山西村》里的“\myrule{7}”两句诗,朋友看了觉得很贴切。
    \item 
    行至群山深处,见到一挂瀑布飞泻而下,水石激荡,轰鸣作响,于老师回头对学生们说:“这不就是古诗中写的‘\myrule{9}’嘛!”
\end{enumerate}

\end{multicols}

\noindent\textbf{参考答案:}

\begin{enumerate}[label=(\arabic{enumi})]
    \item 
    海日生残夜\quad 江春入旧年
    \item 
    山重水复疑无路\quad 柳暗花明又一村
    \item 
    飞流直下三千尺\quad 疑是银河落九天(飞湍瀑流争喧豗\quad 砯崖转石万壑雷)
\end{enumerate}

\end{document}

image.png

也许可以试试amsmath提供的flalign,找好合适的对齐点位。

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign}
\max\enspace &\sum_{i=1}^np_if_i(s_i)&\mathrm{(3-1)}&& \\
\mathrm{s.t.}\enspace&\sum_{j=1}^{n+1}x_{0,j}=\sum_{i=0}^{n}x_{i,n+1}=1,&\mathrm{(3-2)}&& \\
&\sum_{j=0,j\neq i}^nx_{j,i}=\sum_{j=1,j\neq i}^{n+1}x_{i,j}=y_i,&\mathrm{(3-3)}&& \\
&\sum_{i=1}^{n}s_{i}+\sum_{i=0}^{n}\sum_{j=1}^{n+1}t_{ij}x_{ij}\leq T_{\max},&\mathrm{(3-4)}&& \\
&s_{i}\leq\tau_{i}y_{i},&\mathrm{(3-5)}&& \\
&1\leq z_{i}\leq n,&\mathrm{(3-6)}&& \\
&z_{i}-z_{j}+1\leq n(1-x_{ij}),&\mathrm{(3-7)}&& \\
&x_{ij}\in\{0,1\},&\mathrm{(3-8)}&& \\
&y_{i}\in\{0,1\},&\mathrm{(3-9)}&& \\
&s_{i}\geq0,&\mathrm{(3-10)}&&
\end{flalign}
\end{document}

image.png

Editted:

BTW,如果想要求和号都对齐,还可以用mathtools宏包的\mathclap:
image.png

感兴趣的自己看看文档吧~可以实现如下效果...

image.png

对于原OP的MWE:

\documentclass{article}

\newcommand{\foo}{target}%<-mark1

\AddToHook{cmd/foo/before}{extra }%<-mark2
\begin{document}%<-mark3
\foo%<-mark4

\renewcommand{\foo}{new target}%<-mark5
\foo%<-mark6
\end{document}

我来尝试理解一下每一步发生的过程(我希望我的理解没有大问题):

  • mark1:一切照常,定义了新命令\foo
  • mark2:在导言区中使用\AddToHook 由于Hook不会物理性地在导言区存在,而是会有一个延迟修补的机制,在此时增加extra 的内容尚且不会直接被写入\foo的定义中
  • mark3:此时begindocument的钩子自动执行,在此时被延迟写入\fooextra 终于被自动修补\foo的定义中
  • mark4:由于自动修补已经完成,此时输出\foo结果为extra target
因为对于通用钩子在使用\UseHookWithArguments进行自动修补的同时会新建这个钩子,而钩子只能被\NewHook一次,因此可以预见这种自动修补只会进行一次,这里在mark3的时刻,已经由通用钩子cmd/foo/begin的自动修补机制实现了对cmd/foo/begin的创建以及补充代码,故后续不会再进行自动修补
  • mark5:重定义\foo的同时,覆盖了原先的自动修补内容extra .且由于cmd/foo/begin钩子已经存在,不会被再次创建,此时可以使用雾月老师指出的『最佳实践』(也即文档section 2.1.1的第三段):
This has the consequence that a command defined or redefined after \begin{document} only uses generic cmd hook code if \AddToHook is called for the first time after the definition is made, or if the command explicitly uses the generic hook in its definition by declaring it with \NewHookPair adding \UseHook as part of the code.
[kimi翻译版] 这意味着,如果一个命令是在\begin{document}之后定义或重新定义的,只有在定义后首次调用\AddToHook,或者命令在定义时明确使用了通用钩子(通过\NewHookPair声明并包含\UseHook作为代码的一部分),该命令才会使用通用命令钩子代码。

(O.S.我好像没在哪看到\NewHookPair的用法,但这里最后一句的说法我猜就是『最佳实践』的方案)

  • mark6:由于没能再次自动“修补”,此时第二次输出的\foo就仅有最近的一次重定义(\renewcommand)的内容。

对于修改版的MWE:

\renewcommand{\foo}{%
\UseHookWithArguments{cmd/foo/before}{0}%
new target%
\UseHookWithArguments{cmd/foo/after}{0}%
}

要注意的是,如前面介绍,在mark3时已经通过唯一的一次自动修补机制"\NewHook"了一个名为cmd/foo/before的Hook,且其内容为在\foo之前添加extra
于是新的MWE中的\renewcommand里,使用\UseHook{cmd/foo/before}或者\UseHookWithArguments{cmd/foo/before}{0}就可以让cmd/foo/before里保存的内容(因为已经"\NewHook"过这个名为cmd/foo/before的Hook了)“再次”直接发挥作用被\Use,“手动”修补得到想要的结果extra new target.


非常感谢雾月老师,同时也有必要再补充一点以方便我的理解:

对于OP已提及的『尝试过的做法』:在\renewcommand之后再次\AddToHook:

\documentclass{article}
\newcommand{\foo}{target}
\AddToHook{cmd/foo/before}{extra }%
\begin{document}%
\LogHook{cmd/foo/before}%First
\foo%

\renewcommand{\foo}{new target}%
\AddToHook{cmd/foo/before}{extra }%
\LogHook{cmd/foo/before}%Second

%因为hookname已经被占用,不会自动修补
\foo% 因此在『已进行的尝试』中同样无效

\UseHook{cmd/foo/before}%
\foo%

% 其实就等价于『最佳实践』的做法,当需要对重定义命令多次Hook时,手动把`\UseHook'写入`\renewcommand'
\end{document}

image.png

第一处LogHook结果:

-> The generic hook 'cmd/foo/before':
> Code chunks:
>     ---
> Document-level (top-level) code (executed last):
>     -> extra 
> Extra code for next invocation:
>     ---
> Rules:
>     ---
> Execution order:
>     ---.

第二处LogHook结果,但因为不会第二次自动修补,进而不生效:

-> The generic hook 'cmd/foo/before':
> Code chunks:
>     ---
> Document-level (top-level) code (executed last):
>     -> extra extra 
> Extra code for next invocation:
>     ---
> Rules:
>     ---
> Execution order:
>     ---.

Happy Hooking!

自行对比。

原来的作者设计\hh的时候是没有考虑到这种直接挖空在段首的情况的

\documentclass[a4paper]{ctexart}
\usepackage[showframe]{geometry}
\usepackage{zhlipsum}
\RequirePackage{xcolor}

\NewDocumentCommand\hha{g}%
{\IfNoValueTF{#1}{\,\underline{\hbox to 1cm{}}\,}{\nolinebreak\textcolor[rgb]{1,0,0}{\underline{#1}}}}

\NewDocumentCommand\hhb{g}%
{\IfNoValueTF{#1}{\,\underline{\hbox to 1cm{}}\,}{\textcolor[rgb]{1,0,0}{\underline{#1}}}}

\begin{document}
    我的答案是什么呢我的答案是什么呢我的答案是什么呢我的答案是什么呢\hha 你好

    我的答案是什么呢我的答案是什么呢我的答案是什么呢我的答案是什么呢\hhb 你好 

  我的答案是什么呢我的答案是什么呢我的答案是什么呢我的答案是什么呢\hha{我能吞下玻璃而不伤身体}

  我的答案是什么呢我的答案是什么呢我的答案是什么呢我的答案是什么呢\hhb{我能吞下玻璃而不伤身体}

  %\hha{我能吞下玻璃而不伤身体}我的答案是什么呢我的答案是什么呢我的答案是什么呢我的答案是什么呢%<---报错

  \hhb{我能吞下玻璃而不伤身体}我的答案是什么呢我的答案是什么呢我的答案是什么呢我的答案是什么呢

\end{document}

image.png

在数学模式中,所有常规的字体默认样式均为斜体

我不太理解你的『教科书』中是什么样子,请截图看看。


Edited:

Thanks to egreg:

\documentclass[tikz]{standalone}
\usepackage{textcomp} % for TS1
\usepackage{amsmath}

\DeclareSymbolFont{textsymbols}{TS1}{\familydefault}{m}{n}
\SetSymbolFont{textsymbols}{bold}{TS1}{\familydefault}{m}{n}

\DeclareMathSymbol{\ulq}{\mathopen}{textsymbols}{39}
\DeclareMathSymbol{\urq}{\mathclose}{textsymbols}{39}
\DeclareMathSymbol{\uprime}{\mathnormal}{textsymbols}{39}

\begin{document}

\begin{tikzpicture}
    \node {\(C' \enspace C\text{\textquotesingle} \enspace \ulq C\urq \enspace C\uprime \)};
\end{tikzpicture}

\end{document}

image.png

Notes:斜体的Cupright single quote感觉很不搭...


Re-Edited:

\documentclass[tikz]{standalone}
\usepackage{amsmath}
\begin{document}

\begin{tikzpicture}
    \node {\(A'B'C' \enspace \mathrm{A}'\mathrm{B}'\mathrm{C}'\)};
\end{tikzpicture}

\end{document}

image.png

另建议把问题描述为:在数学公式中如何输入正体字符....

或者换一个无衬线的数学字体:

\documentclass[tikz]{standalone}
\usepackage{unicode-math}
\setmathfont{Fira Math}
\usepackage{amsmath}
\begin{document}

\begin{tikzpicture}
    \node {\(A'B'C' \enspace \symup{A}'\symup{B}'\symup{C}'\)};
\end{tikzpicture}

\end{document}

image.png

要想全局生效,也可以试试math-style=upright:

\documentclass[tikz]{standalone}
\usepackage[math-style=upright]{unicode-math}
\setmathfont{Fira Math}
\usepackage{amsmath}
\begin{document}

\begin{tikzpicture}
    \node {\(A'B'C'\)};
\end{tikzpicture}

\end{document}

image.png

发布
问题