在獨立類別中使用 chronosys 套件

在獨立類別中使用 chronosys 套件

我想在投影機簡報中包含時間軸。為此我寫了這段程式碼:

\documentclass{article}

\usepackage{chronosys}
\usepackage{xcolor}

\definecolor{first-period}{HTML}{b3e2cd}
\definecolor{second-period}{HTML}{fdcdac}
\definecolor{third-period}{HTML}{cbd5e8}

\begin{document}

\fontfamily{cmss}\selectfont
\definechronoevent{MySmallerEvent}[textstyle=\footnotesize,datestyle=\footnotesize]

\startchronology[startyear=1980,
  stopyear=2020,
  dates=false,
  color=third-period,
  height=7ex]

\chronoperiode[color=first-period, dates=false]{1980}{2000}{}
\chronoperiode[color=second-period, dates=false]{2000}{2010}{}
\chronoperiode[color=third-period, dates=false]{2010}{2020}{}

\chronoMySmallerEvent[textwidth=5ex]{1990}{First event}
\chronoMySmallerEvent[textwidth=8ex]{2005}{Second event}
\chronoMySmallerEvent[textwidth=5ex]{2015}{Third event}

\stopchronology

\end{document}

輸出

時間軸 然後,在適當的框架中我將其放入:

\includegraphics[width=0.8\textwidth, keepaspectratio, trim = 45mm 210mm 45mm 40mm, clip]{timeline.pdf}

這種方法的問題是我必須手動調整修剪值,這非常耗時。

standalone我認為我可以透過使用而不是創建時間軸來避免修剪圖形article,但這就是我得到的:

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.29 \stopchronology
                    
? 
! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.29 \stopchronology
                    
? 
! Missing } inserted.
<inserted text> 
                }
l.29 \stopchronology
                    
? 
! Extra \endgroup.
<recently read> \endgroup 
                          
l.29 \stopchronology
                    
? 
! Extra \endgroup.
\color@endgroup ->\endgraf \endgroup 
                                     
l.31 \end{document}
                   
? 
! Too many }'s.
\endsa@boxit ...dvarwidth \color@endgroup \egroup 
                                                  
l.31 \end{document}
                   
? 

關於如何解決這個問題有什麼想法嗎?

答案1

首先,時間順序似乎與 的時間軸相符\textwidth,因此您需要將其放入小型頁面中。其次,它不會創建邊界框,因此獨立裁剪掉右側的一部分。所以我用 an\hrule來改變寬度而不改變高度(\rule會增加一個額外的空白行)。

\documentclass{standalone}

\usepackage{chronosys}
\usepackage{xcolor}

\definecolor{first-period}{HTML}{b3e2cd}
\definecolor{second-period}{HTML}{fdcdac}
\definecolor{third-period}{HTML}{cbd5e8}

\begin{document}
\begin{minipage}[t][1in][s]{4in}% set height to 1 in, width to 4 in
\hrule width\textwidth height0pt%bounding box?
\fontfamily{cmss}\selectfont
\definechronoevent{MySmallerEvent}[textstyle=\footnotesize,datestyle=\footnotesize]
%
\startchronology[startyear=1980,
  stopyear=2020,
  dates=false,
  color=third-period,
  height=7ex]
%
\chronoperiode[color=first-period, dates=false]{1980}{2000}{}
\chronoperiode[color=second-period, dates=false]{2000}{2010}{}
\chronoperiode[color=third-period, dates=false]{2010}{2020}{}
%
\chronoMySmallerEvent[textwidth=5ex]{1990}{First event}
\chronoMySmallerEvent[textwidth=8ex]{2005}{Second event}
\chronoMySmallerEvent[textwidth=5ex]{2015}{Third event}
%
\stopchronology
\vss% shrink bottom
\end{minipage}
\end{document}

相關內容