我正在尝试类似表格的东西,其中有一个 ID(标识)和 URL。它看起来像这样:
ID url
I16 \url{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=72WUR/HES_1276&finalterm=5.1.3.15&data=enzyme}
I1 \url{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=97STA/SUA_1365&finalterm=Reaction:\%20\%20D-glucose\%206-phosphate(aq)\%20=\%20D-fructose\%206-phosphate(aq)&data=enzyme}
I2 \url{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=88LIM/RAI_1287&finalterm=D-glyceraldehyde\%203-phosphate(aq)\%20=\%20glycerone\%20phosphate(aq)&data=enzyme}
能否使 ID、I16、I1 等对齐?我尝试使用表格,但无法实现。
答案1
使用tabularx
环境以及X
不执行完全对齐的列类型版本应该可以完成这项工作。但一定要确保使用url
选项hyphens
、spaces
和加载包obeyspaces
。
% (parts of preamble copied from OP's earlier postings)
\documentclass[12pt,twoside]{report}
\usepackage[headheight=18pt,a4paper, width=150mm,top=25mm, bottom=25mm,
bindingoffset=6mm,headsep=18pt]{geometry}
\usepackage[spanish,es-noquoting]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\usepackage[hyphens,spaces,obeyspaces]{url}
\usepackage[colorlinks,urlcolor=black]{hyperref} % optional
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{} lL @{}}
\toprule
ID & URL
\\ \midrule
I16 &
\url{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=72WUR/HES_1276&finalterm=5.1.3.15&data=enzyme}
\\ \addlinespace
I1 &
\url{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=97STA/SUA_1365&finalterm=Reaction:\%20\%20D-glucose\%206-phosphate(aq)\%20=\%20D-fructose\%206-phosphate(aq)&data=enzyme}
\\ \addlinespace
I2 &
\url{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=88LIM/RAI_1287&finalterm=D-glyceraldehyde\%203-phosphate(aq)\%20=\%20glycerone\%20phosphate(aq)&data=enzyme}
\\ \bottomrule
\end{tabularx}
\end{document}
答案2
桌子
在我看来,这些链接太长了,除非你明确需要这样写出来,否则无法显示完整的链接。我假设你已经在使用该hyperref
包(由于\url
),所以我建议改用\href
命令,如下例所示(请注意,你随时可以更改链接的颜色,我保留了默认框以清楚地表明它们是链接)。它使链接紧凑,但仍然包含完整的 URL(将鼠标悬停在 PDF 输出上将显示它):
\documentclass{report}
\usepackage{hyperref}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular}{l l}
\toprule
ID & Link\\
\midrule
I16 & \href{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=72WUR/HES_1276&finalterm=5.1.3.15&data=enzyme}{randr.nist.gov}\\
I1 & \href{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=97STA/SUA_1365&finalterm=Reaction:\%20\%20D-glucose\%206-phosphate(aq)\%20=\%20D-fructose\%206-phosphate(aq)&data=enzyme}{randr.nist.gov}\\
I2 & \href{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=88LIM/RAI_1287&finalterm=D-glyceraldehyde\%203-phosphate(aq)\%20=\%20glycerone\%20phosphate(aq)&data=enzyme}{randr.nist.gov}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
线
事实上,我甚至建议根本不使用表格。该\href
命令可以轻松地在一行中创建这些链接。这可能更适合您的口味:
\documentclass{report}
\usepackage{hyperref}
\begin{document}
(...) and the details of each ID can be found by clicking on them, bringing you to the randr.nist.gov site:
\href{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=72WUR/HES_1276&finalterm=5.1.3.15&data=enzyme}{I16},
\href{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=97STA/SUA_1365&finalterm=Reaction:\%20\%20D-glucose\%206-phosphate(aq)\%20=\%20D-fructose\%206-phosphate(aq)&data=enzyme}{I1}
and \href{https://randr.nist.gov/enzyme/DataDetails.aspx?ID=88LIM/RAI_1287&finalterm=D-glyceraldehyde\%203-phosphate(aq)\%20=\%20glycerone\%20phosphate(aq)&data=enzyme}{I2}.
\end{document}