使用 LaTeX 的 Material Design 卡片

使用 LaTeX 的 Material Design 卡片

我正在尝试使用 LaTeX 制作一些受 Google 材料设计启发的卡片。但是,我遇到了一个问题。

我找不到在顶部显示绿色条的方法。[至于符号,我还没考虑过。] 目前我正在使用 TikZ。如果有更好的方法,请告诉我。

这是我目前所拥有的:

我目前得到的

代码:

\usepackage{tikz}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{color}

\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}

\renewcommand\familydefault{\sfdefault}

\definecolor{unigreen}{RGB}{0, 149, 69}

\newcommand{\materialCards}[5][0]{
    \tikz\node[fill=white,
    draw=gray!30,
    blur shadow={shadow blur steps=3},
    inner xsep = 1em,
    inner ysep = 0,
    align=left,
    text width = .4\textwidth,
    ] {
        \begin{mdframed}[hidealllines=true,backgroundcolor=unigreen]
            \bfseries\large \textcolor{white}{#2 - #3}
        \end{mdframed}
        \normalfont #4\\[0.5em]
        \begin{tabular}{cl}
            Symbol  &   #5\\
            Symbol  &   #1
        \end{tabular}
        \vspace{0.3em}
    };
    \vspace{0.2cm}
}

\begin{document}
\materialCards[Homepage]{1}{Title}{Here will be some kind of description. Just don't mind the text at the moment...}{Address}
\end{document}

这就是我想要的。

我希望得到什么

答案1

这是使用 Tikz 的版本。与 Ignasi 一样,我假设标题中的数字应该随着每张卡片而增加,因此您可以使用计数器自动执行此操作。

输出

在此处输入图片描述

代码

\documentclass{article}
\usepackage{tikz}
\usepackage{marvosym,fontawesome} % for the symbols

\definecolor{greencard}{RGB}{0,153,99}

\newcounter{cards}
\setcounter{cards}{1}

\newcommand\materialCards[3][.5\textwidth]{%
\tikz{%
    \node[draw=greencard, fill=greencard, minimum height=8mm, text width=#1, font=\bfseries\sffamily, text=white, align=left] (title) {\arabic{cards}~\textemdash~#2};
    \node[align=left, anchor=north west, text width=#1-2\pgflinewidth, text depth=2cm] (desc) at (title.south west) {#3};
    \node[anchor=north west, minimum size=1cm, font=\Large] (symbol1) at (desc.south west) {\faMapMarker};
    \node[anchor=north west, minimum size=1cm, font=\Large] (symbol2) at (symbol1.south west) {\Mundus};
%
    \node[anchor=west, text width=#1-1cm, minimum height=1cm] (add) at (symbol1.east) {Address};
    \node[anchor=west, text width=#1-1cm, minimum height=1cm] (web) at (symbol2.east) {Website};
    \draw[gray, ultra thin, dashed] (symbol2.south east) -- (symbol1.north east);
    \draw[gray, ultra thin, dashed] (symbol1.south west) -- (add.south east);
    \draw[gray, ultra thin, dashed] (desc.south west) -- (desc.south east);
    \draw[gray, thin] (title.north west) rectangle (web.south east);
}%
\stepcounter{cards}%
\par%
\vspace{\baselineskip}%
}

\begin{document}
\materialCards[8cm]{Title}{Here will be some kind of description. Just don't mind the text at the moment... Here will be some kind of description. Just don't mind the text at the moment....}

\materialCards[8cm]{Another Title}{Here will be some other kind of description. Just don't mind the text at the moment... Here will be some other kind of description. Just don't mind the text at the moment...}
\end{document}

答案2

您可以尝试使用tcolorbox。这里有一个起点。

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{fontawesome}

\newtcolorbox[auto counter]{materialCards}[1]{%
enhanced,
drop shadow,
sharp corners,
colframe=green!60!black,
fonttitle=\bfseries,
boxrule=0pt,
drop shadow,
title={\thetcbcounter - #1},
}

\begin{document}

\begin{materialCards}{Title}
Here ill be som kind of description, Just don't mind the text at the moment \dots
\\[5mm]
\begin{tabular}{cl}
\faMapMarker & Address\\
\faGlobe & Website\\
\end{tabular}
\end{materialCards}

\begin{materialCards}{Another card}
Here ill be som kind of description, Just don't mind the text at the moment \dots
\\[5mm]
\begin{tabular}{cl}
\faMapMarker & Address\\
\faGlobe & Website\\
\end{tabular}
\end{materialCards}
\end{document}

在此处输入图片描述

相关内容