
따라해보려고 해요이 예테이블의 글꼴을 변경하려면 아래 코드에 대한 부분적인 솔루션입니다. 글꼴을 변경하기 위한 값도 가져올 수 없습니다.
\documentclass{article}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[format=plain,
labelformat=simple,
font={small,sf,bf},
indention=0cm,
labelsep=period,
justification=centering,
singlelinecheck=true,
tableposition=top,
figureposition=bottom]{caption}
\makeatletter
\appto\@floatboxreset{%
\ifx\@captype\andy@table
\ttfamily
\fi
}
\def\andy@table{table}
\makeatother
\begin{document}
Blah blah. Should be a serif font.
\begin{table}
\caption{My title}
\begin{center}
\begin{tabular}{l c c c }
\hline
& treat x time & treat x time x female & treat x time x female \\
\hline
(Intercept) & $-0.03$ & $0.01$ & $-0.83^{*}$ \\
& $[-0.16;\ 0.10]$ & $[-0.13;\ 0.15]$ & $[-0.93;\ -0.73]$ \\
v1 & $-0.06$ & $-0.06$ & $-0.07$ \\
& $[-0.23;\ 0.11]$ & $[-0.23;\ 0.11]$ & $[-0.18;\ 0.05]$ \\
v2 & $0.05$ & $-0.03$ & \\
& $[-0.04;\ 0.15]$ & $[-0.16;\ 0.11]$ & \\
\hline
\multicolumn{4}{l}{\scriptsize{$^*$ 0 outside the confidence interval. Fixed effect of time treated as factor.}}
\end{tabular}
\label{m123}
\end{center}
\end{table}
Blah blah. Should be a serif font.
\end{document}
답변1
$
불필요한 곳(즉, 거의 모든 곳)을 제거하면 됩니다 .
\documentclass{article}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[format=plain,
labelformat=simple,
font={small,sf,bf},
indention=0cm,
labelsep=period,
justification=centering,
singlelinecheck=true,
tableposition=top,
figureposition=bottom,
]{caption}
\makeatletter
\appto\@floatboxreset{%
\ifx\@captype\andy@table
\ttfamily
\fi
}
\def\andy@table{table}
\makeatother
\begin{document}
Blah blah. Should be a serif font.
\begin{table}
\centering
\caption{My title}\label{m123}
% fix the overfull
\small\addtolength{\tabcolsep}{-2pt}
\begin{tabular}{ l c c c }
\hline
& treat x time & treat x time x female & treat x time x female \\
\hline
(Intercept) & -0.03 & 0.01 & -0.83$^{*}$ \\
& [-0.16; 0.10] & [-0.13; 0.15] & [-0.93; -0.73] \\
v1 & -0.06 & -0.06 & -0.07 \\
& [-0.23; 0.11] & [-0.23; 0.11] & [-0.18; 0.05] \\
v2 & 0.05 & -0.03 & \\
& [-0.04; 0.15] & [-0.16; 0.11] & \\
\hline
\multicolumn{4}{l}{%
\scriptsize $^*$ 0 outside the confidence interval. Fixed effect of time treated as factor.%
}
\end{tabular}
\end{table}
Blah blah. Should be a serif font.
\end{document}
몇 가지 추가 참고 사항.
\label
참조하는 객체 옆에 를 배치합니다 . 이 경우에는\caption
\scriptsize
주장을 받아들이지 않습니다.환경
center
에서는 사용하지 마십시오 .table
\centering
외부 프로그램에서 생성된 테이블을 터치하고 싶지 않다면 좀 더 어렵습니다.
\documentclass{article}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[format=plain,
labelformat=simple,
font={small,sf,bf},
indention=0cm,
labelsep=period,
justification=centering,
singlelinecheck=true,
tableposition=top,
figureposition=bottom]{caption}
\makeatletter
\appto\@floatboxreset{%
\ifx\@captype\andy@table
\ttfamily
\everymath{\fam=\group@mathtt\relax\andy@changemathcodes}%
\fi
}
\def\andy@table{table}
\let\andy@space\ %
\AtBeginDocument{%
\check@mathfonts
\sbox\z@{$\mathtt{\xdef\group@mathtt{\gdef\noexpand\group@mathtt{\the\fam}}\group@mathtt}$}%
\def\andy@changemathcodes{%
\count@="2\group@mathtt00 \advance\count@`-\mathcode`-=\count@
\count@="4\group@mathtt00 \advance\count@`[\mathcode`[=\count@
\count@="5\group@mathtt00 \advance\count@`]\mathcode`]=\count@
\count@="0\group@mathtt00 \advance\count@`;\mathcode`;=\count@
\def\ {\mathopen{\andy@space}}%
}%
}
\makeatother
\begin{document}
Blah blah. Should be a serif font; here's math: $a+b$
\begin{table}
\centering
\caption{With dollars}
% fix the overfull
\small\addtolength{\tabcolsep}{-2pt}
\begin{tabular}{ l c c c }
\hline
& treat x time & treat x time x female & treat x time x female \\
\hline
(Intercept) & $-0.03$ & $0.01$ & $-0.83^{*}$ \\
& $[-0.16;\ 0.10]$ & $[-0.13;\ 0.15]$ & $[-0.93;\ -0.73]$ \\
v1 & $-0.06$ & $-0.06$ & $-0.07$ \\
& $[-0.23;\ 0.11]$ & $[-0.23;\ 0.11]$ & $[-0.18;\ 0.05]$ \\
v2 & $0.05$ & $-0.03$ & \\
& $[-0.04;\ 0.15]$ & $[-0.16;\ 0.11]$ & \\
\hline
\multicolumn{4}{l}{%
\scriptsize$^*$ 0 outside the confidence interval. Fixed effect of time treated as factor.%
}
\end{tabular}
\end{table}
\begin{table}[htp]
\centering
\caption{My title}\label{m123}
% fix the overfull
\small\addtolength{\tabcolsep}{-2pt}
\begin{tabular}{ l c c c }
\hline
& treat x time & treat x time x female & treat x time x female \\
\hline
(Intercept) & -0.03 & 0.01 & -0.83$^{*}$ \\
& [-0.16; 0.10] & [-0.13; 0.15] & [-0.93; -0.73] \\
v1 & -0.06 & -0.06 & -0.07 \\
& [-0.23; 0.11] & [-0.23; 0.11] & [-0.18; 0.05] \\
v2 & 0.05 & -0.03 & \\
& [-0.04; 0.15] & [-0.16; 0.11] & \\
\hline
\multicolumn{4}{l}{%
\scriptsize $^*$ 0 outside the confidence interval. Fixed effect of time treated as factor.%
}
\end{tabular}
\end{table}
Blah blah. Should be a serif font; here's math: $a+b$.
\end{document}
보시다시피 출력은 동일합니다.
답변2
이는 활용고정 폭 텍스트를 사용하도록 모든 수학 출력을 변경할 수 있습니까?\everymath
패치 에 적절한 명령을 추가하려면 다음을 \@floatboxreset
수행하십시오.
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\appto\@floatboxreset{%
\ifx\@captype\andy@table
\ttfamily
% https://tex.stackexchange.com/q/119879/5764
\everymath{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}%
\fi
}
\def\andy@table{table}
\makeatother
\begin{document}
\begin{table}
\begin{tabular}{ l *{3}{c} }
\hline
& treat x time & treat x time x female & treat x time x female \\
\hline
(Intercept) & $-0.03$ & $0.01$ & $-0.83^{*}$ \\
& $[-0.16;\ 0.10]$ & $[-0.13;\ 0.15]$ & $[-0.93;\ -0.73]$ \\
v1 & $-0.06$ & $-0.06$ & $-0.07$ \\
& $[-0.23;\ 0.11]$ & $[-0.23;\ 0.11]$ & $[-0.18;\ 0.05]$ \\
v2 & $0.05$ & $-0.03$ & \\
& $[-0.04;\ 0.15]$ & $[-0.16;\ 0.11]$ & \\
\hline
\multicolumn{4}{l}{\scriptsize{$^*$ 0 outside the confidence interval. Fixed effect of time treated as factor.}}
\end{tabular}
\end{table}
\end{document}
불행하게도 단항 빼기 주위의 간격은 일정하지 않습니다. 예를 들어 다음을 참조하세요 $a - b$ $-b$ $[-b]$ ${-}b$
.
{-}
필요한 경우 단항 빼기를 강제로 적용하려면 the를 사용해야 할 수도 있습니다 .