在日历上标记“当前日期”

在日历上标记“当前日期”

我使用 overlead,现在我想在月历上突出显示当前日期。本指南:带有 TIKZ-PGF 的日历:如何突出显示当前日期?。但是我的日历显示的位置不对(请看图片)谢谢 在此处输入图片描述 我的代码:

\documentclass[a4paper,10pt]{article}
\usepackage[a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm]{geometry}
%pagesize,
\usepackage[T1]{fontenc}
\usepackage[justification=centering]{caption}   
\usepackage{graphicx}
\usepackage[romanian]{babel}
%\usepackage{libertine} % fonts not installed here
\usepackage{translator, tikz, array} % pgfcalendar loaded later with \usetikzlibrary{calendar}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
%\usepackage{xcolor} % loaded by tikz
\usepackage{tabu}
\usepackage{epstopdf}
%\usepackage{color} % unnecessary, because xcolor already loaded
%\usepackage{pgf} % loaded by tikz

%=========================================================
%== Page characteristics (Page Setup) ====================
% using geometry would be better


\usetikzlibrary{calendar,shapes.geometric}
\usetikzlibrary{calc}
%== Define colors =================================
\definecolor{rozmam}{RGB}{242,172,184}
\newcommand{\troz}{\textcolor{rozmam}}


\makeatletter%
% these days, \tikzset is used
\tikzset{%
    day headings/.style={day heading=#1}, % \tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
    day heading/.style={}, % \tikzstyle{day heading}=[]
    day letter headings/.style={% \tikzstyle{day letter headings} ...
        execute before day scope={ \ifdate{day of month=1}{%
          \pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}%
          \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
          \pgftransformyshift{-\pgf@ya}
          \foreach \d/\l in {0/M,1/T,2/W,3/T,4/F,5/S,6/S} {
            \pgf@xa=\d\pgf@xa%
            \pgftransformxshift{\pgf@xa}%
            \pgftransformyshift{\pgf@ya}%
            \node[every day,day heading]{\l};%
          }
        }{}%
      }
    }
}
\makeatother



\begin{document}


\foreach \n in {2,...,2}{

\pgfcalendar{cal}{2018-\n-01}{2018-\n-last}
{
% added to ensure every day starts on a new page
\newpage
\thispagestyle{empty}
% remember day and month

\begin{minipage}{3cm}
\captionsetup{skip=4pt, minmargin=0cm, maxmargin=0cm}
{
  \centering
\includegraphics[width=2cm]{Image/ABC.jpg}
 \captionof*{figure}{\textcolor{red}{ABC}}
}
\end{minipage}%
\hspace*{0.8cm} 
\begin{minipage}{7cm}
\centering
\Huge  \textcolor{blue}{Planner} \\

\edef\pagedayofmonth{\pgfcalendarcurrentday}%
\edef\pagemonth{\pgfcalendarcurrentmonth}%
\noindent
{
\Huge \pgfcalendarweekdayname{\pgfcalendarcurrentweekday}
\Huge \bfseries
\pgfcalendarcurrentday{}\\[20pt]

}
\end{minipage}
\begin{tikzpicture}[remember picture, overlay, transform shape]
  \node [anchor=north east, inner sep=8pt, xshift = -15pt]
    at (current page.north east)
    {
      \begin{tikzpicture}[every node/.append style = {anchor=center}]
        \calendar (mycal) [dates=2018-\n-01 to 2018-\n-last,
        week list,
        day text=\%d0,
        month label above centered,
        month text={\%mt} \%y-,
        day xshift = 0.8cm,
        day headings=gray,
        day letter headings
    ]
    if (Saturday) [rozmam]
    if (Sunday)   [rozmam]
    % just set another text color; nodes={draw} could be added, but the rectangle is too large
    if (day of month=\pagedayofmonth) [cyan]
    ;
    % draw a frame around the day
    \draw[green,thick,rounded corners]
        ($(mycal-2018-\pagemonth-\pagedayofmonth.south east) + (-1.5mm,1.5mm)$) rectangle 
        ($(mycal-2018-\pagemonth-\pagedayofmonth.north west) + (1.5mm,-1.5mm)$);


      \end{tikzpicture}
    };
\end{tikzpicture}

\\[30pt]
\pagebreak
%{}
 }
}
\end{document}

答案1

下面的代码编译三次确实产生了正确的输出(我只是删除了多余的,并将和\\更改为和,并用 TeX Live 和 MikTeX 上通常可用的图像替换了你的图像)。\edef\pagedayofmonth\edef\pagemonth\xdef\pagedayofmonth\xdef\pagemonth

\documentclass[a4paper,10pt]{article}
\usepackage[a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm]{geometry}
%pagesize,
\usepackage[T1]{fontenc}
\usepackage[justification=centering]{caption}   
\usepackage{graphicx}
\usepackage[romanian]{babel}
%\usepackage{libertine} % fonts not installed here
\usepackage{translator, tikz, array} % pgfcalendar loaded later with \usetikzlibrary{calendar}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
%\usepackage{xcolor} % loaded by tikz
\usepackage{tabu}
\usepackage{epstopdf}
%\usepackage{color} % unnecessary, because xcolor already loaded
%\usepackage{pgf} % loaded by tikz

%=========================================================
%== Page characteristics (Page Setup) ====================
% using geometry would be better


\usetikzlibrary{calendar,shapes.geometric}
\usetikzlibrary{calc}
%== Define colors =================================
\definecolor{rozmam}{RGB}{242,172,184}
\newcommand{\troz}{\textcolor{rozmam}}


\makeatletter%
% these days, \tikzset is used
\tikzset{%
    day headings/.style={day heading=#1}, % \tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
    day heading/.style={}, % \tikzstyle{day heading}=[]
    day letter headings/.style={% \tikzstyle{day letter headings} ...
        execute before day scope={ \ifdate{day of month=1}{%
          \pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}%
          \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
          \pgftransformyshift{-\pgf@ya}
          \foreach \d/\l in {0/M,1/T,2/W,3/T,4/F,5/S,6/S} {
            \pgf@xa=\d\pgf@xa%
            \pgftransformxshift{\pgf@xa}%
            \pgftransformyshift{\pgf@ya}%
            \node[every day,day heading]{\l};%
          }
        }{}%
      }
    }
}
\makeatother



\begin{document}


\foreach \n in {2,...,2}{

\pgfcalendar{cal}{2018-\n-01}{2018-\n-last}
{
% added to ensure every day starts on a new page
\newpage
\thispagestyle{empty}
% remember day and month

\begin{minipage}{3cm}
\captionsetup{skip=4pt, minmargin=0cm, maxmargin=0cm}
{
  \centering
\includegraphics[width=2cm]{example-image-duck}
 \captionof*{figure}{\textcolor{red}{ABC}}
}
\end{minipage}%
\hspace*{0.8cm} 
\begin{minipage}{7cm}
\centering
\Huge  \textcolor{blue}{Planner} \\

\xdef\pagedayofmonth{\pgfcalendarcurrentday}%
\xdef\pagemonth{\pgfcalendarcurrentmonth}%
\noindent
{
\Huge \pgfcalendarweekdayname{\pgfcalendarcurrentweekday}
\Huge \bfseries
\pgfcalendarcurrentday{}\\[20pt]

}
\end{minipage}
\begin{tikzpicture}[remember picture, overlay, transform shape]
  \node [anchor=north east, inner sep=8pt, xshift = -15pt]
    at (current page.north east)
    {
      \begin{tikzpicture}[every node/.append style = {anchor=center}]
        \calendar (mycal) [dates=2018-\n-01 to 2018-\n-last,
        week list,
        day text=\%d0,
        month label above centered,
        month text={\%mt} \%y-,
        day xshift = 0.8cm,
        day headings=gray,
        day letter headings
    ]
    if (Saturday) [rozmam]
    if (Sunday)   [rozmam]
    % just set another text color; nodes={draw} could be added, but the rectangle is too large
    if (day of month=\pagedayofmonth) [cyan]
    ;
    % draw a frame around the day
    \draw[green,thick,rounded corners]
        ($(mycal-2018-\pagemonth-\pagedayofmonth.south east) + (-1.5mm,1.5mm)$) rectangle 
        ($(mycal-2018-\pagemonth-\pagedayofmonth.north west) + (1.5mm,-1.5mm)$);


      \end{tikzpicture}
    };
\end{tikzpicture}

\pagebreak
%{}
 }
}
\end{document}

相关内容