Forgot password
 Register account
View 451|Reply 6

想做一个*号标记的公式引用,多个*要怎么弄

[Copy link]

414

Threads

1641

Posts

15

Reputation

Show all posts

abababa posted 2022-2-8 15:18 |Read mode
如题,我想在公式后面用*,**,***这样的标记来替代编号,我想定义一个mymark,如下:
  1. \newcommand\mymark[1][1]{\textcolor{blue}{\text{$~\foreach \n in{1,...,#1}{\ast}~$}}}
Copy the Code
就是默认不加参数,用\mymark时是1个*,然后用\mymark{n}时就是n个*。但上面那个不行,请教这个要怎么弄?

673

Threads

110K

Posts

218

Reputation

Show all posts

kuing posted 2022-2-8 15:27
能用啊
  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \usepackage{tikz}
  4. \newcommand\mymark[1][1]{\textcolor{blue}{\text{$~\foreach \n in{1,...,#1}{\ast}~$}}}
  5. \begin{document}
  6. $a\mymark$
  7. $a$\mymark
  8. $a\mymark[4]$
  9. $a$\mymark[5]
  10. \[a\mymark[6]\]
  11. \end{document}
Copy the Code
这些都没问题

414

Threads

1641

Posts

15

Reputation

Show all posts

original poster abababa posted 2022-2-8 15:50
回复 2# kuing
原来如此,我用的时候用的是花括号,2楼用的是方括号,是不是我定义的时候有什么问题啊,一般的参数不都是放在花括号里的吗。

673

Threads

110K

Posts

218

Reputation

Show all posts

kuing posted 2022-2-8 15:54
回复 3# abababa

???可选参数用方括号这是 latex 的常识,你用这么久竟然不知道?

414

Threads

1641

Posts

15

Reputation

Show all posts

original poster abababa posted 2022-2-8 15:57
回复 4# kuing

是的,不知道,很少用可选参数。

673

Threads

110K

Posts

218

Reputation

Show all posts

kuing posted 2022-2-8 15:59
回复 5# abababa

n 次根号 \sqrt[3]{2} 里的 [3] 不就是可选参数吗

414

Threads

1641

Posts

15

Reputation

Show all posts

original poster abababa posted 2022-2-8 16:22
回复 6# kuing

对以前用过的一些,就是习惯地那样写,没想过是不是可选参数。

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-19 21:24 GMT+8

Powered by Discuz!

Processed in 0.013817 seconds, 22 queries