
대부분 숫자 열로 구성된 테이블 설정이 있습니다. 그러나 때로는 빈 항목이 있는 일부 셀이 있으며, 현재 Excel CSV 파일에서는 "---"로 출력됩니다. 셀이 소수점 이하 자리에 정렬되기를 원할 때까지 모든 것이 잘 작동했습니다. 내 문서의 다른 곳에서 사용 중인 패키지 S
열 에서 좋은 결과를 찾았습니다 . siunitx
그래서 나는 그것들을 사용하기로 결정했습니다. 그러나 이제 "---"가 있는 "빈" 셀이 문제와 충돌을 일으키고 있습니다. 문제를 해결하기 위해 여기 스레드의 몇 가지 방법을 사용하려고 했습니다.
Siunitx: 잘못된 숫자 입력 '-'을 처리하는 방법은 무엇입니까?
성공하지 못했습니다( 를 사용하거나 \textemdash
중괄호로 셀을 보호함 {---}
). 또한 string type
매뉴얼에서 읽은 대로 열 스타일을 추가하려고 시도했는데 pgfplotstable
이로 인해 pgfplotstable
추가 처리 없이 단순히 셀을 읽을 수 있게 되었습니다.
내가 사용하는 방법에 따라, 나는 Missing \endcsname inserted
그 방법을 시도해 볼 때 얻거나 textemdash
, Could not parse input '---' as a floating point number
이 방법 또는 저 방법과 전혀 결혼하지 않습니다. 나는 이것을 사용하고 싶습니다 pgfplotstable
. 이것은 내 문서에 포함해야 하는 이 형식의 약 45개 정도의 외부 테이블 중 하나일 뿐이며 모든 테이블을 라텍스 코드로 수동으로 조판하는 것을 선호하지 않습니다.
실제로는 작동하지 않기 때문에 여기에 "mwe"가 있습니다. :(
\documentclass{memoir}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{longtable}
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}
\begin{document}
\pgfplotstabletypeset[%
col sep=comma,%
columns/atomnum/.style={int detect,column type=c},%
columns/atomtype/.style={string type,column type=c},%
columns/x/.style={string type,column type=S},%
columns/y/.style={string type,column type=S},%
columns/z/.style={string type,column type=S},%
columns/nmrshieldtens/.style={column type=S},%
columns/nmrscaledshifts/.style={column type=S},%
header=true,
every head row/.style={before row=\toprule, after row=\midrule\endhead},%
every last row/.style={after row=\bottomrule}%
]{nankakurineSI.csv}%
\end{document}
외부 파일을 사용하고 있는데 여기에 어떻게 제공하는지 잘 모르겠어서 아래에 파일 내용을 포함시켰습니다. 43행과 48행에서 문제 지점을 볼 수 있습니다.
atomnum,atomtype,x,y,z,nmrshieldtens,nmrscaledshifts
1, C ,2.645924,-0.284964,1.121739,145.6803,38.1985
2, C ,3.061887,-0.314747,-1.738533,138.1991,45.6797
3, C ,4.192868,-0.744373,-0.81303,152.3163,31.5625
4, C ,3.609622,-1.293585,0.487818,158.2814,25.5974
5, H ,2.179934,-0.733573,2.004648,29.7536,2.1014
6, H ,3.222428,0.584598,1.466674,30.9379,0.9171
7, H ,2.482083,-1.204262,-2.037409,28.7647,3.0903
8, H ,3.460033,0.135058,-2.653243,29.1953,2.6597
9, H ,4.8172,-1.495056,-1.309066,30.3061,1.5489
10, H ,4.826006,0.126259,-0.596497,30.5419,1.3131
11, H ,4.407002,-1.530092,1.200573,30.3571,1.4979
12, H ,3.088045,-2.236207,0.278539,30.219,1.636
13, C ,-0.54058,-1.145592,0.929915,143.9137,39.9651
14, C ,0.528585,-0.902319,-0.152946,143.2553,40.6235
15, C ,1.550392,0.221805,0.156845,124.581,59.2978
16, C ,0.851532,1.450518,0.80068,133.676,50.2028
17, C ,0.027293,1.042491,2.023216,147.7008,36.178
18, C ,-1.109706,0.152585,1.53285,140.8497,43.0291
19, H ,-0.057217,-1.683382,1.759072,30.1175,1.7375
20, H ,0.034879,-0.650236,-1.095222,30.0622,1.7928
21, H ,1.056471,-1.849267,-0.318437,29.5661,2.2889
22, H ,1.648183,2.146325,1.095154,30.7693,1.0857
23, H ,0.631687,0.517402,2.770335,29.9253,1.9297
24, H ,-0.375923,1.941621,2.506378,30.4385,1.4165
25, H ,-1.749305,-0.12778,2.381335,30.3971,1.4579
26, C ,-0.086446,2.231626,-0.127235,121.2219,62.6569
27, C ,-2.015491,0.916314,0.549213,113.5813,70.2975
28, H ,-0.424133,3.132366,0.42693,29.8436,2.0114
29, H ,0.446378,2.597638,-1.011354,28.8531,3.0019
30, C ,-1.676245,-2.03098,0.39515,138.255,45.6238
31, H ,-2.274539,-2.393781,1.244793,30.6875,1.1675
32, H ,-1.25699,-2.917557,-0.100028,30.3609,1.4941
33, C ,-2.623346,-1.297773,-0.5652,156.7968,27.082
34, H ,-2.066223,-1.014811,-1.468623,29.9263,1.9287
35, C ,-3.14384,-0.01614,0.093255,140.5753,43.3035
36, H ,-2.46664,1.767252,1.104586,29.9266,1.9284
37, H ,-3.843967,0.497571,-0.574314,29.7727,2.0823
38, H ,-3.719835,-0.292135,0.988647,31.0288,0.8262
39, C ,-3.780339,-2.203913,-0.982867,159.2459,24.6329
40, H ,-4.373272,-2.494855,-0.106965,31.3512,0.5038
41, H ,-4.447095,-1.695357,-1.687373,30.882,0.973
42, H ,-3.413599,-3.118855,-1.46021,30.8992,0.9558
43, N ,-1.242229,1.456093,-0.582487,{---},{---}
44, C ,-2.064595,2.286645,-1.451361,138.6569,45.2219
45, H ,-1.433234,2.735618,-2.223064,29.7894,2.0656
46, H ,-2.833329,1.693382,-1.950341,29.0105,2.8445
47, H ,-2.559918,3.103363,-0.892348,30.514,1.341
48, N ,2.23005,0.694822,-1.070475,{---},{---}
49, H ,1.515066,0.996756,-1.729488,30.5467,1.3083
답변1
이제 거의 다 왔습니다. S
열 유형을 사용하려면 을 사용해야 하며 string type
, 그렇게 하는 경우 를 로 바꾸면 ---
됩니다 \textemdash
. 를 설정하여 PGFPlotstable이 교체를 처리하도록 할 수 있습니다 string replace={---}{\textemdash}
.
열 유형을 사용할 때 할당할 공간이 얼마나 되는지 알 수 S
있도록 숫자 형식도 지정해야 합니다 . siunitx
숫자에 소수 구분 기호 앞에 한 자리, 뒤에 여섯 자리가 있고 기호가 포함된 경우 이라고 말합니다 column type={S[table-format=-1.6]}
.
\documentclass{memoir}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{longtable}
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}
\begin{document}
\pgfplotstabletypeset[%
col sep=comma,
string replace={---}{\textemdash}, %
columns/atomnum/.style={int detect,column type=c},%
columns/atomtype/.style={string type,column type=c},%
columns/x/.style={string type,column type={S[table-format=-1.6]}},%
columns/y/.style={string type,column type={S[table-format=-1.6]}},%
columns/z/.style={string type,column type={S[table-format=-1.6]}},%
columns/nmrshieldtens/.style={string type, column type={S[table-format=3.4]}},%
columns/nmrscaledshifts/.style={
string type,
column type={S[table-format=2.4]}},%
header=true,multicolumn names,
every head row/.style={before row=\toprule, after row=\midrule\endhead},%
every last row/.style={after row=\bottomrule}%
]{
atomnum,atomtype,x,y,z,nmrshieldtens,nmrscaledshifts
1, C ,2.645924,-0.284964,1.121739,145.6803,38.1985
2, C ,3.061887,-0.314747,-1.738533,138.1991,45.6797
3, C ,4.192868,-0.744373,-0.81303,152.3163,31.5625
4, C ,3.609622,-1.293585,0.487818,158.2814,25.5974
5, H ,2.179934,-0.733573,2.004648,29.7536,2.1014
6, H ,3.222428,0.584598,1.466674,30.9379,0.9171
7, H ,2.482083,-1.204262,-2.037409,28.7647,3.0903
8, H ,3.460033,0.135058,-2.653243,29.1953,2.6597
9, H ,4.8172,-1.495056,-1.309066,30.3061,1.5489
10, H ,4.826006,0.126259,-0.596497,30.5419,1.3131
11, H ,4.407002,-1.530092,1.200573,30.3571,1.4979
12, H ,3.088045,-2.236207,0.278539,30.219,1.636
13, C ,-0.54058,-1.145592,0.929915,143.9137,39.9651
14, C ,0.528585,-0.902319,-0.152946,143.2553,40.6235
15, C ,1.550392,0.221805,0.156845,124.581,59.2978
16, C ,0.851532,1.450518,0.80068,133.676,50.2028
17, C ,0.027293,1.042491,2.023216,147.7008,36.178
18, C ,-1.109706,0.152585,1.53285,140.8497,43.0291
19, H ,-0.057217,-1.683382,1.759072,30.1175,1.7375
20, H ,0.034879,-0.650236,-1.095222,30.0622,1.7928
21, H ,1.056471,-1.849267,-0.318437,29.5661,2.2889
22, H ,1.648183,2.146325,1.095154,30.7693,1.0857
23, H ,0.631687,0.517402,2.770335,29.9253,1.9297
24, H ,-0.375923,1.941621,2.506378,30.4385,1.4165
25, H ,-1.749305,-0.12778,2.381335,30.3971,1.4579
26, C ,-0.086446,2.231626,-0.127235,121.2219,62.6569
27, C ,-2.015491,0.916314,0.549213,113.5813,70.2975
28, H ,-0.424133,3.132366,0.42693,29.8436,2.0114
29, H ,0.446378,2.597638,-1.011354,28.8531,3.0019
30, C ,-1.676245,-2.03098,0.39515,138.255,45.6238
31, H ,-2.274539,-2.393781,1.244793,30.6875,1.1675
32, H ,-1.25699,-2.917557,-0.100028,30.3609,1.4941
33, C ,-2.623346,-1.297773,-0.5652,156.7968,27.082
34, H ,-2.066223,-1.014811,-1.468623,29.9263,1.9287
35, C ,-3.14384,-0.01614,0.093255,140.5753,43.3035
36, H ,-2.46664,1.767252,1.104586,29.9266,1.9284
37, H ,-3.843967,0.497571,-0.574314,29.7727,2.0823
38, H ,-3.719835,-0.292135,0.988647,31.0288,0.8262
39, C ,-3.780339,-2.203913,-0.982867,159.2459,24.6329
40, H ,-4.373272,-2.494855,-0.106965,31.3512,0.5038
41, H ,-4.447095,-1.695357,-1.687373,30.882,0.973
42, H ,-3.413599,-3.118855,-1.46021,30.8992,0.9558
43, N ,-1.242229,1.456093,-0.582487,---,---
44, C ,-2.064595,2.286645,-1.451361,138.6569,45.2219
45, H ,-1.433234,2.735618,-2.223064,29.7894,2.0656
46, H ,-2.833329,1.693382,-1.950341,29.0105,2.8445
47, H ,-2.559918,3.103363,-0.892348,30.514,1.341
48, N ,2.23005,0.694822,-1.070475,---,---
49, H ,1.515066,0.996756,-1.729488,30.5467,1.3083
}%
\end{document}