在下面的代码中,marginnote 在逻辑上与 lipsum 文本对齐。我想将 marginnote 与节标题对齐。
用起来有什么技巧呢?
% Source : http://tex.stackexchange.com/questions/36432/tiks-draw-in-left-margin-putting-old-calendar-style-date-in-margin
\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\newcommand*{\Date}[4]{%
\begin{tikzpicture}[show background rectangle,inner frame sep=0pt,text width=1cm,align=center]
\node [fill=orange] at (0,0) (dayofweek) {#1};
\node [fill=white ] at ($(dayofweek) +(0,-\baselineskip)$) (dayofmonth) {#2};
\node [fill=white ] at ($(dayofmonth) +(0,-\baselineskip)$) (month) {#3};
\node [fill=orange] at ($(month) +(0,-\baselineskip)$) (dayofmonth) {#4};
\end{tikzpicture}
}
\reversemarginpar % To put the margin pars on the left
\begin{document}
\section*{One day} \marginnote{\Date{Mon.}{28}{Nov}{2011}}
\noindent\lipsum[1]
\end{document}
答案1
放在\marginnote
里面\section*
(并添加) 的参数\normalfont\normalsize
。
\section*{One day\marginnote{\normalfont\normalsize\Date{Mon.}{28}{Nov}{2011}}}
编辑:更好的方法是将的定义更改\marginfont
为\normalfont\normalsize
:
\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{marginnote}
\reversemarginpar % To put the margin pars on the left
\renewcommand*{\marginfont}{\normalfont\normalsize}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\newcommand*{\Date}[4]{%
\begin{tikzpicture}[show background rectangle,inner frame sep=0pt,text width=1cm,align=center]
\node [fill=orange] at (0,0) (dayofweek) {#1};
\node [fill=white ] at ($(dayofweek) +(0,-\baselineskip)$) (dayofmonth) {#2};
\node [fill=white ] at ($(dayofmonth) +(0,-\baselineskip)$) (month) {#3};
\node [fill=orange] at ($(month) +(0,-\baselineskip)$) (dayofmonth) {#4};
\end{tikzpicture}
}
\begin{document}
\section*{One day\marginnote{\Date{Mon.}{28}{Nov}{2011}}}
\noindent\lipsum[1]
\end{document}
最后,但并非最不重要的一点是,您可以使用第二个最佳参数更改其垂直定位\marginnote
:
\section*{One day} \marginnote{\Date{Mon.}{28}{Nov}{2011}}[-30pt]