考虑以下最小工作示例:
\documentclass[reqno]{article}
\usepackage{amsfonts, amsmath, amssymb, amsthm}
\usepackage[T1]{fontenc}
\renewcommand{\sfdefault}{cmbr}
\begin{document}
\begin{flushleft}
Author \\ \vspace{0.5em}
\hrule \vspace{1.5em}
\large{\sffamily{\itshape{Subtitle:}}} \\
\LARGE{\sffamily{\itshape{Title}}} \\
\end{flushleft} \vspace{10em}
Content.
\end{document}
我想在标题栏(标题和副标题)旁边放一个大数字,比如 1.01。它的高度和cmbright
字体应该与标题栏相同,并且数字和标题栏之间的间距可以调整。另外,我刚刚注意到标题和副标题并不是完全齐左的。有什么办法可以解决这个问题吗?非常感谢!
编辑:数字应该位于标题栏的左边...抱歉,我忘了从一开始就提到这一点。
答案1
我会为此创建一个新命令:
\documentclass{article}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\renewcommand{\sfdefault}{cmbr}
\newsavebox{\titleblockbox}
\newcommand{\titleblock}[5][2cm]{%
% #1 = space, #2 = author, #3 = pretitle, #4 = title, #5 = number
\begin{flushleft}
\sffamily
#2\\[0.5em]
\hrule
\vspace{1.5em}
\sbox{\titleblockbox}{%
\slshape\large
\begin{tabular}[b]{@{}l@{}}
#3\\[1ex]
\LARGE#4
\end{tabular}%
}%
\usebox{\titleblockbox}\hspace{#1}%
\resizebox{!}{\ht\titleblockbox}{\huge#5}%
\end{flushleft}
\vspace{10em}
}
\begin{document}
\titleblock
{Author}
{Subtitle}
{\negthinspace Title}
{10.1}
Content.
\end{document}
默认间距为 2cm,但可以使用可选参数进行更改:
\titleblock[1cm]
{Author}
{Subtitle}
{\negthinspace Title}
{10.1}
仅需1cm。
如果要设置标题栏左侧的数字,请按以下步骤操作:
\documentclass{article}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\renewcommand{\sfdefault}{cmbr}
\newsavebox{\titleblockbox}
\newcommand{\titleblock}[5][2cm]{%
% #1 = space, #2 = author, #3 = pretitle, #4 = title, #5 = number
\begin{flushleft}
\sffamily
#2\\[0.5em]
\hrule
\vspace{1.5em}
\sbox{\titleblockbox}{%
\slshape\large
\begin{tabular}[b]{@{}l@{}}
#3\\[1ex]
\LARGE#4
\end{tabular}%
}%
\resizebox{!}{\ht\titleblockbox}{\huge#5}%
\hspace{#1}%
\usebox{\titleblockbox}%
\end{flushleft}
\vspace{10em}
}
\begin{document}
\titleblock
{Author}
{Subtitle}
{\negthinspace Title}
{10.1}
Content.
\end{document}
答案2
最简单的方法是使用graphicx
以\resizebox{<height>}{!}{<number>}
满足您的需求(我们\smash
这样做是为了避免对垂直对齐产生任何影响):
\documentclass{article}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\renewcommand{\sfdefault}{cmbr}
\begin{document}
\begin{flushleft}
Author \\ \vspace{0.5em}
\hrule \vspace{1.5em}
\large{\sffamily{\itshape{Subtitle:}}} \\
\LARGE{\sffamily{\itshape{Title}}} \hspace{5em} \smash{\resizebox{4\baselineskip}{!}{10.1}} \\
\end{flushleft} \vspace{10em}
Content.
\end{document}
水平对齐标题根据字体来说是正确的。如果您希望稍微调整一下,可以在前面加上\hspace*{-0.2em}
,例如。
相反的情况:
\documentclass{article}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\renewcommand{\sfdefault}{cmbr}
\begin{document}
\begin{flushleft}
Author \\ \vspace{0.5em}
\hrule \vspace{1.5em}
\raisebox{.5\dimexpr\baselineskip-\height}[0pt]{\resizebox{7\baselineskip}{!}{10.1}} \hspace*{5em}
\begin{tabular}{@{}l}
\large\sffamily\itshape{Subtitle:}\strut \\
\LARGE\sffamily\itshape{Title}\strut
\end{tabular}
\end{flushleft} \vspace{10em}
Content.
\end{document}
答案3
\documentclass[margin=5mm]{standalone}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
%===========
\begin{document}
%===========
%\MyHead
\newcommand{\MyHead}[3]{\mathord{
\begin{tikzpicture}[baseline=0ex, font=\normalsize]
\node[scale=1, align=left] at (0,0) {Title: #1 \\ Subtitle: #2};
\node[scale=4.5, align=left] at (5,0) {#3};
\end{tikzpicture}
}}
$\MyHead{This is my Title}{This is my Subtitle}{10.1}$
%Optionally not in the math-mode, so without \mathord{} and $-signs
%===========
\end{document}
%===========