Sagittarius Rover
Sagittarius Rover
这家伙很懒,什么也没写!

注册于 3年前

回答
534
文章
0
关注者
21

maybe related: https://github.com/James-Yu/LaTeX-Workshop/issues/3988

我曾经自定义使用过musixflx宏包需要的musixflx命令,在LW上是有效的,感觉就是James Yu没有在上游提供支持,上面的issues好像也没有下文了....

off-topic:

李清老师在2012年重排过一版《金瓶梅》,可见这个需要魔法的链接

为避免网络问题,这里上传相关的文件以供参考:

其中实现了类似的效果,可惜...我看不太懂李清在.sty中的设置:

image.png

期待题主的排版大作早日问世~

请提供在别人的电脑上如何复现你的问题。无法复现的问题是玄学。不应该被提问。

建议你在vscode右下角的编码处尝试修改编码方式。

(感觉这份文件烂完了...)

image.png

使用tcolorbox宏包的默认样式即可。

请在终端输入texdoc tcolorbox,或者看这个链接

请给一份完整的可直接编译的代码,并且分点详细说明哪些部分还不满意,以方便潜在的回答者逐一解决。

昨天修习了一下zref-lastpage,如果不想用圈圈的话,可以试试下面的代码:

P.S.在calc宏包中提供了名为\ratio的用于计算两个<dim>之比,最好是不要使用\ratio作为宏的名称

\documentclass[tikz,border=5pt]{standalone}
\usepackage[totpages,lastpage]{zref}
\usetikzlibrary{calc}
\def\hlen{1.25cm}
\def\headradius{10pt}
\def\hwidth{2cm}
\def\hfillwidth{.567*\hwidth}

\newcommand*\pageProgressBar{%
    \ifnum\ztotpages=0\relax
        \def\myratio{1}
    \else%
        \pgfmathsetmacro{\myratio}{\value{page}/\ztotpages}
    \fi
    \def\hfillwidth{\myratio*\hwidth}
    \begin{tikzpicture}[scale=3]
        \draw[rounded corners = \headradius, fill = black!30] (0,0) rectangle ++ (\textwidth, .5cm);
        \fill[rounded corners = \headradius, fill = violet!90] (0,0) rectangle ++ (\myratio*\textwidth, .5cm);
    \end{tikzpicture}
}
\begin{document}
\foreach \p in {1, ..., 20}{%
    \pageProgressBar
    \newpage
}
\end{document}

(上述甚至抄了一些鱼老师的代码和思路)

  • 一方面,如果希望从更加用户友好层面出发,要获取LastPaage索引的数值问题可以通过refcount提供的\getrefbykeydefault命令获取,或者直接通过zref-lastpage获得;这里有一个较为详细的总结~
  • 另一方面,由于LastPage的值的取得需要等第一轮编译到shipout阶段之后把页码信息(应该恰好是\@abspage@last)写入.aux内,而使用\ztotpages等方法在第一轮的初始值是0(使用\@abspage@last的初始值为\maxdimen),因为这里需要在不能获取到LastPage的时候先编译tikz的计算,因此对第一轮需要进行特殊判断以避免除零错误。这一过程写入.aux是由latex自动完成的,而如果需要写入其他信息,可以参考雾月老师的这个解答,或者使用zref的机制写入新的property。

maybe related in the hypererf documentation:

image.png

Claim:我总是喜欢尽可能短的MWE,优秀的MWE基本能控制到10行以内

我尝试对你的MWE缩了一下行...并试着结合啸行老师的做法给了一个尝试...

\documentclass[UTF8,a4paper,openany]{book} %% openany可以让你的页面少几面
\usepackage{ctex}
\ctexset{
    contentsname={\textit{Contents}},
    listfigurename={\zihao{3}\centering List of figures},
    bibname={References},
}
\usepackage[colorlinks=true]{hyperref}
\usepackage{graphicx}
\begin{document}
WWW

QQQ

\newpage
\phantomsection
\addcontentsline{toc}{chapter}{ABSTRACT}
\centerline{\bfseries ABSTRACT}

AAA

\tableofcontents

\listoffigures
\addcontentsline{toc}{chapter}{LIST OF FIGURES} 

\ExplSyntaxOn
\int_step_inline:nn {4}{%
    \chapter{Chapter \int_to_Roman:n {#1}}
    \section{111}
    \section{222}
    \section{333}
    \int_step_inline:nn {4}{%
        \begin{figure}
            \centering
            \includegraphics{example-image}
            \caption{figure-{##1}}
        \end{figure}
    }
}
\ExplSyntaxOff

\begin{thebibliography}{9}
\bibitem{111} 1111
\bibitem{222} 222
\bibitem{333} 333
\bibitem{444} 444
\end{thebibliography}
\addcontentsline{toc}{chapter}{REFERENCES} 
 
\end{document}

请看VCR:

mweres.gif

不可以想空行就空行!!!

我没看出来的你的图示是按什么对齐的,你的图示看上去很丑......

可能的正确示例如下:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{align*}
    SSE &= \sum_{i=1}^n(y_i-\hat{y_i})\\
    SST &= \sum_{i=1}^n(y_i-\bar{y})
    \end{align*}
\end{document}

image.png

公式环境不可以空行!!!你的MWE并不work...

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
   
    \begin{align}
    SSE = \sum_{i=1}^n(y_i-\hat{y_i})\notag\\
    SST = \sum_{i=1}^n(y_i-\bar{y})\notag\\
    
    \end{align}
\end{document}

倒数第三行!!!不允许空行!!!
这将会报错:

 SSE = \sum _{i=1}^n(y_i-\hat {y_i})\notag \\ SST = \sum _{i=1}^n(y_i\ETC.
! Paragraph ended before \align was complete.
<to be read again>
                   \par
l.9

@u141196 如果我没有记错的话,你的上一个问题没有做任何回复。提问请不要突然消失


请你明确你的问题。

如果是“如何输入这些图标”,我们默认这是在标准文档类下进行的,下面是最简单的MWE:

% LuaLaTeX
\documentclass{article}
\usepackage{fontawesome5}
\usepackage{xcolor}
\colorlet{accent}{blue!70!black}
\begin{document}

\faIcon{qq} 

\faIcon{github}

\textcolor{red}{\faIcon{qq}}

\textcolor{accent}{\faIcon{github}}

\end{document}

image.png

如若不然,请说明你的准确需求。同时,一个问题请只聚焦一个目标

我也抽空试了下...核心基本都是用decorations.pathreplacing提供的brace

image.png

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\draw (0,.15) -- (0,0) node[left,yshift=.12cm] {Hello} -- (5,0) -- (5,.15) decorate [decoration={brace,amplitude=5pt}] { (0,.15) -- (5,.15)  node[midway,yshift=.35cm] {50 dollars}};

\draw (0,-1+.15) -- (0,-1) node[left,yshift=.12cm] {Hello} -- (7,-1) -- (7,-1+.15) (0,-1-.15) -- (0,-1) (7,-1-.15) -- (7,-1) decorate [decoration={brace,,amplitude=5pt,mirror}] { (0,-1-.15) -- (7,-1-.15)  node[midway,yshift=-.53cm] {70 dollars}};

\draw (5,-1+.15) decorate [decoration={brace,amplitude=5pt}] { -- (7,-1+.15)  node[midway,yshift=.35cm] {? dollars}};

\draw[dashed] (5,0) -- (5,-1);
\end{tikzpicture}
\end{document}

image.png

Welcome to latexstudio!

@u3945 但是同时有个小建议:
应该使用markdown的围栏代码块将你的代码包围,否则会出现丢失\的现象,你可以使用“补充回答”功能,让这部分代码正确高亮。

image.png

PS.国外不知道有没有线段图这一称呼,不知道有没有造好的轮子。

@u686 Thanks to David Carilsle again🙌

感觉舍弃:
\thickline 以及 \thickline[<dim>]

使用:
\thickline{} 以及 \thickline{<dim>}

在这种情况下也并非就很用户不友好(算是一种trade off between 代码量 与 syntax的易用性 ...)

仍然不太优雅(本可以避免一些dummy的语句的)... 就当抛砖引玉了... 一定有更符合tikz-style更优雅的办法:

我下面取了个巧,利用重复绘制右⚪来规避计算交点坐标,因为从OP的目标和工作量权衡来看,显式得到这两个坐标似乎不是必须的...

基本思路:

  • 先画右圆(实线)
  • 再画左圆把右圆的一部分盖住
  • 最后画右圆(虚线)
\documentclass[border=8pt,tikz]{standalone}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\begin{document}
    \begin{tikzpicture}
        \path [draw,very thick,->] node at (-.3,-.3) {$O$} (-0.5,0) -- (8,0) node[anchor=north] {$x$};
        \path [draw,very thick,->] (0,-0.5) -- (0,6.1) node[anchor=east] {$y$};
        \node at (7.5,5.5) {$\mathbb{R}^{2}$};
        \draw[very thick,blue,dashed,-] (0.5,0.5) -- (6.5,0.5) -- (6.5,5) --(0.5,5)--(0.5,0.5);
        \node at (6.2,1) {$\Lambda$};
        \node at (5.5,3) {$S$};
        \draw (5,3) circle (1.2);
        \draw[fill=white] (3,3) circle (1.5);
        \draw[dashed] (5,3) circle (1.2);
        \draw[pattern=north west lines,draw=red]  (3,3) circle (1.5);
        \node[fill=white,rounded corners,below of=3] at (2.5,4) {$B$};
        \node at (2,1.3) {$ {\color{red}\partial B=B_{0}}$};
    \end{tikzpicture}  
\end{document}

image.png

MWE编译报错啊,缺少amsmath宏包...

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
    \lipsum[2]
    \begin{equation*}
    y=\beta_0 + \beta_{1}X
    \end{equation*}
    \lipsum[2]
    \[  
        y=\beta_0 + \beta_{1}X
    \]
    \lipsum[2]
\end{document}

BTW,lshort-zh-cn第四章都有吧...

image.png

有群友于 2025-03-9 反馈称确实会在这一步出现卡住的情况,但这似乎是这个页面的bug,实际上的.log文件已经安装结束了(如果你等得足够久的话),你可以测试下查看.log能否看到形如“欢迎来到TeX的世界”之类的欢迎语,如果可以,应该是可以(通过ctrl+Z或者ctrl+C)之类的方法关闭的。

usrguide中,如@u101077 老师所言,要使用\NewExpandableDocumentCommand才可以在表格内正确展开,但与此同时又有如下限制:

image.png

无法将唯一的参数定义为O型...

我不太懂展开,也不太懂是否有好的办法绕开这一限制,但OP又说:

我知道有很多表格宏包能做这件事情。我的问题是如何自定义具有一个可选参数的thickhline命令?或者有没有其他打包控制表格线粗细命令的方法?

因此我虽然发现booktabs中的toprule命令完全符合这一要求...但不确定OP是否“允许”站在前人的肩膀上,下面是直接偷Plain-TeX的方法,个人觉得这样的话,这个横线命令应该会比自己定义的更sound...

\documentclass{article}
\makeatletter
\newdimen\myheavyrulewidth
\myheavyrulewidth=1.5bp %<-default width here
\newdimen\belowrulesep
\newdimen\belowbottomsep
\newdimen\aboverulesep
\newdimen\abovetopsep
\newdimen\@aboverulesep
\newdimen\@belowrulesep
\newcount\@thisruleclass
\newcount\@lastruleclass
\@lastruleclass=0
\newdimen\@thisrulewidth
\def\futurenonspacelet#1{\def\@BTcs{#1}%
   \afterassignment\@BTfnslone\let\nexttoken= }
\def\@BTfnslone{\expandafter\futurelet\@BTcs\@BTfnsltwo}
\def\@BTfnsltwo{\expandafter\ifx\@BTcs\@sptoken\let\next=\@BTfnslthree
   \else\let\next=\nexttoken\fi \next}
\def\@BTfnslthree{\afterassignment\@BTfnslone\let\next= }
\def\Thickhline{\noalign{\ifnum0=`}\fi%<- modified from \toprule
  \@aboverulesep=\abovetopsep
  \global\@belowrulesep=\belowrulesep %global cos for use in the next noalign
  \global\@thisruleclass=\@ne
  \@ifnextchar[{\@BTrule}{\@BTrule[\myheavyrulewidth]}}%<- modified here
\def\@BTrule[#1]{%
  \ifx\longtable\undefined
    \let\@BTswitch\@BTnormal
  \else\ifx\hline\LT@hline
    \nobreak
    \let\@BTswitch\@BLTrule
  \else
    \let\@BTswitch\@BTnormal
  \fi\fi
  \global\@thisrulewidth=#1\relax
  % \ifnum\@thisruleclass=\tw@\vskip\@aboverulesep\else
  % \ifnum\@lastruleclass=\z@\vskip\@aboverulesep\else
  % \ifnum\@lastruleclass=\@ne\vskip\doublerulesep\fi\fi\fi
  \@BTswitch}
\AtBeginDocument{%
   \providecommand*\CT@arc@{}}%% colortbl support
\def\@BTnormal{%
    {\CT@arc@\hrule\@height\@thisrulewidth}%
    \futurenonspacelet\@tempa\@BTendrule}
\def\@BLTrule{\@ifnextchar({\@@BLTrule}{\@@BLTrule()}}
\def\@@BLTrule(#1){\@setrulekerning{#1}%
\global\@cmidlb\LT@cols
\ifnum0=`{\fi}%
\noalign{\ifnum0=`}\fi
\futurenonspacelet\@tempa\@BTendrule}
\def\@BTendrule{\ifx\@tempa\toprule\global\@lastruleclass=\@thisruleclass
  \else\ifx\@tempa\midrule\global\@lastruleclass=\@thisruleclass
  \else\ifx\@tempa\bottomrule\global\@lastruleclass=\@thisruleclass
  \else\ifx\@tempa\cmidrule\global\@lastruleclass=\@thisruleclass
  \else\ifx\@tempa\specialrule\global\@lastruleclass=\@thisruleclass
  \else\ifx\@tempa\addlinespace\global\@lastruleclass=\@thisruleclass
  \else\global\@lastruleclass=\z@\fi\fi\fi\fi\fi\fi
  % \ifnum\@lastruleclass=\@ne\relax\else\vskip\@belowrulesep\fi
  \ifnum0=`{\fi}}
\makeatother
\begin{document}

\begin{tabular}{ll}
\Thickhline
  a & b \\
\hline
  c & d \\
\Thickhline[1bp]
\end{tabular}

\end{document}

image.png


感觉抄的很不整洁(neat),上面应该还存在一些可以删的unused命令...

发布
问题