简体   繁体   English

Latex \\ newcommand参数

[英]Latex \newcommand argument

I have a Latex text for which I want to write a very basic class to render. 我有一个Latex文本,我想写一个非常基本的类来渲染。 basically all of the text's commands need defining. 基本上所有文本的命令都需要定义。 I am doing well so far until I hit this: 到目前为止,我做得很好,直到我点击这个:

\\swordfootnote{1}{}{Philemon 1:23}{crossReference}{}{See \\swordxref{Col.1.7}{Col. 1:7}}

Basically this is a fancy footnote which I simply, at this moment at least, want to render as a footnote. 基本上这是一个花哨的脚注,我至少在这个时刻想要作为一个脚注呈现。 It has 6 arguments, but I really only need the last one, which is the footnote text. 它有6个参数,但我真的只需要最后一个,这是脚注文本。

I have done the following: 我做了以下事情:

\\RequirePackage{hyperref} \\newcommand{\\swordxref}[2]{\\hyperref{#1}{#2}} \\newcommand{\\swordfootnote}[6]{\\footnote{#6}}

I am getting on compiling messages that there is a superfluous }. 我正在编译消息,这是多余的}。

! Argument of \\@finalstrut has an extra }. <inserted text> \\par l.9 ...ver. 9}; See \\swordxref{Eph.3.1}{Eph. 3:1}}

Any suggestions as to what I am doing wrong? 关于我做错了什么的任何建议?

Your use of \\hyperref is incorrect. 您对\\hyperref使用不正确。 The "two-argument" version of \\hyperref uses the interface \\hyperref的“双参数”版本使用该接口

\hyperref[<label>]{<text>}

with square brackets for the first argument. 用方括号表示第一个参数。

Here's a minimal example showing the usage: 这是一个显示用法的最小示例:

在此输入图像描述

\documentclass{article}
\usepackage[paperheight=20\baselineskip]{geometry}% Just for this example
\usepackage{hyperref}
\newcommand{\swordxref}[2]{\hyperref[#1]{#2}}
\newcommand{\swordfootnote}[6]{\footnote{#6}}
\begin{document}

\section{A section}\label{sec:section}

See~\swordxref{sec:section}{this section} or a footnote\swordfootnote{1}{2}{3}{4}{5}{See~\swordxref{sec:section}{this section}.}.

\end{document}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM