我想写一个文档,将两个图和与图对应的两个函数组合在一起。应该有两个这样的组彼此对齐。下面是一张我的意思的图片:
这看起来已经与我想要实现的非常相似,但是我不喜欢“公式”列中的对齐。
我目前正在使用tabularx
带有框架线(显然)和两个的环境来执行此操作minipages
。带有公式的列如下所示:
\multicolumn{2}{|c|}{\(\displaystyle s(t) = \sigma \left(t\! +\!
\frac{T_i}{2}\right) - \sigma\left(t - \frac{T_i}{2}\right)\) \hfill
\horizontaltransform[F]{} \hfill \(\displaystyle\undersl{S}(f) = T_i
\cdot \frac{\sin(\pi f T_i)}{\pi f T_i}\)}\\ \hline
(verticaltransform
这是我整理的 TikZ 宏)
我该如何改进,让公式居中于顶部的列,让变换符号居中于列?这是写法吗,还是有更好的选择?代码看起来很复杂,一旦我继续使用其他函数及其频谱,我就会担心不同的高度。
梅威瑟:
\documentclass{article}
\usepackage{tabularx, multicol, graphicx, trfsigns}
\usepackage[margin=1cm]{geometry}
\renewcommand\tabularxcolumn[1]{m{#1}}% for vertical centering text in X column
\begin{document}
\scriptsize
\begin{minipage}{.49\textwidth}
\begin{tabularx}{\textwidth}{|X|X|}
\hline
\includegraphics[width=4cm]{example-image-a} &%
\includegraphics[width=4cm]{example-image-a} \\ \hline
\multicolumn{2}{|c|}{ \hfill \(\displaystyle s(t) = \sigma \left(t\! +\! \frac{T_i}{2}\right) - \sigma\left(t - \frac{T_i}{2}\right)\) \hfill \(\laplace\) \hfill \(\displaystyle\undersl{S}(f) = T_i \cdot \frac{\sin(\pi f T_i)}{\pi f T_i}\) \hfill }\\ \hline
\end{tabularx}
\end{minipage}\hfill%
\begin{minipage}{.49\textwidth}
\begin{tabularx}{\textwidth}{|X|X|}
\hline
\includegraphics[width=4cm]{example-image-a} &%
\includegraphics[width=4cm]{example-image-a} \\ \hline
\multicolumn{2}{|c|}{ \hfill \(\displaystyle s(t) = \sigma \left(t\! +\! \frac{T_i}{2}\right) - \sigma\left(t - \frac{T_i}{2}\right)\) \hfill \(\laplace\) \hfill \(\displaystyle\undersl{S}(f) = T_i \cdot \frac{\sin(\pi f T_i)}{\pi f T_i}\) \hfill }\\ \hline
\end{tabularx}
\end{minipage}
\end{document}
答案1
我只需使用一个独特的东西tabular
和一个支柱(\rule[-12pt]{0pt}{30pt}
)来扩大带有公式的行。
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{amsmath}
\usepackage{tabularx, multicol, graphicx, trfsigns}
\renewcommand\tabularxcolumn[1]{>{\centering\arraybackslash}m{#1}}% for vertical centering text in X column
\begin{document}
\begin{center}
\scriptsize\begin{tabular}{|c|c|c|c|}
\hline
\includegraphics[width=4cm]{example-image-a} & \includegraphics[width=4cm]{example-image-a} & \includegraphics[width=4cm]{example-image-a} & \includegraphics[width=4cm]{example-image-a} \\ \hline
\multicolumn{2}{|c|}{\rule[-12pt]{0pt}{30pt}\(\displaystyle s(t) = \sigma \left(t + \frac{T_i}{2}\right) - \sigma\left(t - \frac{T_i}{2}\right)\hfill\laplace\hfill%\undersl where is this command defined?
\underline{S}(f) = T_i \cdot \frac{\sin(\pi f T_i)}{\pi f T_i}\)}&\multicolumn{2}{c|}{\(\displaystyle s(t) = \sigma \left(t + \frac{T_i}{2}\right) - \sigma\left(t - \frac{T_i}{2}\right)\hfill\laplace\hfill%\undersl where is this command defined?
\underline{S}(f) = T_i \cdot \frac{\sin(\pi f T_i)}{\pi f T_i}\) }\\ \hline
\end{tabular}
\end{center}
\end{document}
答案2
- 您的公式太宽(即使在 \scriptsize 字体大小中也是如此),以至于可以按照您想要的方式容纳两个单元格的宽度
- 为了解决这个问题,您需要扩大表格宽度:
- 一种方法是通过使用数据包
\adjustwidth
中的宏来局部增加文本宽度changepage
- 另一种方法是旋转表格或将其置于
landscape
页面方向
- 一种方法是通过使用数据包
- 在第一种情况下,重写方程代码(可以编译)后,您可以获得:
\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{hhline, % new
makecell, % new
tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{trfsigns}
\usepackage{amsmath}
%\renewcommand\tabularxcolumn[1]{m{#1}}% for vertical centering text in X column
\usepackage[strict]{changepage}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[11]
\begin{adjustwidth}{}{-\marginparwidth}
\scriptsize
\setlength\tabcolsep{4pt}
\setcellgapes{4pt}
\makegapedcells
\centering\medskip
\begin{tabularx}{\linewidth}{|X X||X X |}
\hhline{|--||--|}
\includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-b}
& \includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-b} \\
\hhline{|--||--|}
\multicolumn{2}{|>{$}c<{$}||}{
s(t) = \sigma \left(t{+}\dfrac{T_i}{2}\right) - \sigma\left(t{-}\dfrac{T_i}{2}\right)
\ \laplace\
\underline{S}(f) = T_i \dfrac{\sin(\pi f T_i)}{\pi f T_i}
\rule{4.4em}{0pt} % manually adjusted
}
&
\multicolumn{2}{>{$}c<{$}|}{
s(t) = \sigma \left(t{+}\dfrac{T_i}{2}\right) - \sigma\left(t{-}\dfrac{T_i}{2}\right)
\ \laplace\
\underline{S}(f) = T_i \dfrac{\sin(\pi f T_i)}{\pi f T_i}
\rule{4.4em}{0pt} % manually adjusted
} \\
\hhline{|--||--|}
\end{tabularx}
\end{adjustwidth}
\end{document}
& \multicolumn{1}{>{$\displaystyle}c<{$}|}{
s(t) = \sigma \left(t{+}\dfrac{T_i}{2}\right) - \sigma\left(t{-}\dfrac{T_i}{2}\right)
& \multicolumn{1}{>{$\displaystyle}c<{$}|}{
\underline{S}(f) = T_i \dfrac{\sin(\pi f T_i)}{\pi f T_i}
} \\
\hhline{|--||--|}
\end{tabularx}
\end{adjustwidth}
\end{document}
(红线表示页面布局)
在第二种情况下使用
sidewaystable˙ environment you can increase font size to ˙\footnotesize
:\documentclass{article} \usepackage{geometry} \usepackage{graphicx} \usepackage{hhline, % new makecell, % new tabularx} \newcolumntype{C}{>{\centering\arraybackslash}X} \usepackage{trfsigns} \usepackage{amsmath} %\renewcommand\tabularxcolumn[1]{m{#1}}% for vertical centering text in X column \usepackage{rotating} %---------------- show page layout. don't use in a real document! \usepackage{showframe} \renewcommand\ShowFrameLinethickness{0.15pt} \renewcommand*\ShowFrameColor{\color{red}} %---------------------------------------------------------------% \usepackage{lipsum} \begin{document} \lipsum[11] \begin{sidewaystable} \footnotesize \setlength\tabcolsep{4pt} \setcellgapes{4pt} \makegapedcells \centering \begin{tabularx}{\linewidth}{|X X||X X |} \hhline{|--||--|} \includegraphics[width=\linewidth]{example-image-a} & \includegraphics[width=\linewidth]{example-image-b} & \includegraphics[width=\linewidth]{example-image-a} & \includegraphics[width=\linewidth]{example-image-b} \\ \hhline{|--||--|} \multicolumn{2}{|>{$}c<{$}||}{ s(t) = \sigma \left(t{+}\dfrac{T_i}{2}\right) - \sigma\left(t{-}\dfrac{T_i}{2}\right) \ \laplace\ \underline{S}(f) = T_i \dfrac{\sin(\pi f T_i)}{\pi f T_i} \rule{5em}{0pt} % manually adjusted } & \multicolumn{2}{>{$}c<{$}|}{ s(t) = \sigma \left(t{+}\dfrac{T_i}{2}\right) - \sigma\left(t{-}\dfrac{T_i}{2}\right) \ \laplace\ \underline{S}(f) = T_i \dfrac{\sin(\pi f T_i)}{\pi f T_i} \rule{5em}{0pt} % manually adjusted } \\ \hhline{|--||--|} \end{tabularx} \end{sidewaystable} \end{document}